Flash 視頻廣告的定位兼容性問題
發(fā)布時間:2009-09-13 21:23:53 作者:佚名
我要評論
在項目中,用到了一個Flash視頻廣告,但是該視頻廣告在Firefox中顯示實在是差強人意,居然漂浮在了網(wǎng)站的左上角,該怎么解決這個問題呢?
調(diào)用代碼如下:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<html xmlns="http://www.w3.org/1999/xhtml ">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>無標題文檔</title>
<script language="javascript" type="text/javascript" src="flash.js"></script>
<style type="text/css">
body { height:1000px;width:100%}
.zhans_ship { width:250px; height:200px; Z-INDEX:99999; right: 0px; VISIBILITY: hidden; BORDER-BOTTOM: #000 2px solid; POSITION: absolute; BACKGROUND-COLOR: #000;top:378px;}
.top_ship { width:250px; height:26px; background-image:url(kkkk/msgTopBg.gif);font-family:"宋體"; font-size:12px; color:#FFFFFF;}
.top_ship div { width:150px; height:auto; float:left; line-height:20px;}
.bfq_a {font-size: 12px; background-image: url('kkkk/bomBg.gif');height:15px; line-height:15px; color: #ffffff;padding-top:2px; text-align:center;}
.bfq_a a:link { font-family:"宋體"; font-size:12px; text-decoration:none; color:#FFFFFF;}
.bfq_a a:visited { font-family:"宋體"; font-size:12px; text-decoration:none; color:#FFFFFF;}
.bfq_a a:active { font-family:"宋體"; font-size:12px; text-decoration:none; color:#FFFFFF;}
.bfq_a a:hover { font-family:"宋體"; font-size:12px; text-decoration:none; color:#FFFFFF;}
</style>
</head>
<body>
<div class="zhans_ship" id="eMeng">
<div class="top_ship"><div>視頻廣告:</div><span title=關閉 style="CURSOR: hand;color:white;font-size:12px;font-weight:bold;margin-right:4px; float:right; width:auto; height:auto; margin-top:3px;" onclick=closeDiv() >×</span></div>
<!-- flash 顯示部分 start -->
<div class="mid_ship">
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0 " width="250" height="150">
<param name="movie" value="player.swf">
<param name="quality" value="high">
<param name="allowFullScreen" value="true" />
<param name="FlashVars" value="vcastr_file=http://www.xxx.cn/zhaoshang.flv&vcastr_title=MiningGo&BarColor=0xFFffff&BarPosition=1&IsShowBar=3&BarTransparent=10&LogoText=Zgcjq.COM&IsAutoPlay=1&IsContinue=1" />
<embed src="player.swf" allowFullScreen="true" FlashVars="vcastr_file=http://www.xxx.com/images/zhaoshang.flv&vcastr_title=MiningGo&BarColor=0xFFffff&BarPosition=1&IsShowBar=3&BarTransparent=10&LogoText=Zgcjq.COM&IsAutoPlay=1&IsContinue=1" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer " wmode="transparent" type="application/x-shockwave-flash" width="250" height="150"></embed>
</object>
</div>
<!-- flash 顯示部分 end -->
<div class="bfq_a"><a href="#" target="_blank">大型XX活動</a></div>
</div>
</body>
</html>
flash.js代碼(修改后的)如下:
if(document.all){
window.attachEvent('onload',getMsg);
}else{
window.addEventListener('load',getMsg,false);
}
window.onresize = resizeDiv;
window.onerror = function(){}
var divTop,divLeft,divWidth,divHeight,docHeight,docWidth,objTimer,i = 0;
function getMsg()
{
try{
var eMeng = document.getElementById("eMeng");
/* 為修改前
var docWidth = document.documentElement.clientWidth;
var docHeight = document.documentElement.clientHeight;
*/
//修改后:
var docWidth = getWidth();
var docHeight = getHeight();
divTop = parseInt(eMeng.style.top,10);
divLeft = parseInt(eMeng.style.left,10);
divHeight = parseInt(eMeng.offsetHeight,10);
divWidth = parseInt(eMeng.offsetWidth,10);
eMeng.style.top = parseInt(document.documentElement.scrollTop,10) + docHeight + 10+"px" ;// divHeight
eMeng.style.left = parseInt(document.documentElement.scrollLeft,10) + docWidth - divWidth+"px" ;
eMeng.style.visibility = "visible";
objTimer = window.setInterval("moveDiv()",10)
}catch(e){
}
}
function resizeDiv()
{
i+=1;
try{
var eMeng = document.getElementById("eMeng");
var docWidth = getWidth();
var docHeight = getHeight();
divHeight = parseInt(eMeng.offsetHeight,10)
divWidth = parseInt(eMeng.offsetWidth,10)
eMeng.style.top = docHeight - divHeight + parseInt(document.documentElement.scrollTop,10)+"px" ;
eMeng.style.left = docWidth - divWidth + parseInt(document.documentElement.scrollLeft,10)+"px" ;
}catch(e){}
}
function moveDiv()
{
try
{
var eMeng = document.getElementById("eMeng");
var docWidth = getWidth();
var docHeight = getHeight();
divHeight = parseInt(eMeng.offsetHeight,10);
divWidth = parseInt(eMeng.offsetWidth,10);
if(parseInt(eMeng.style.top,10) <= (docHeight - divHeight + parseInt(document.documentElement.scrollTop,10)))
{
window.clearInterval(objTimer);
objTimer = window.setInterval("resizeDiv()",1);
}
divTop = parseInt(eMeng.style.top,10);
divTop--;
eMeng.style.top = divTop+"px" ;
}catch(e){
}
}
function closeDiv()
{
var eMeng = document.getElementById("eMeng");
eMeng.innerHTML='';
eMeng.style.visibility='hidden';
if(objTimer) window.clearInterval(objTimer);
}
/**
* 獲取屏幕寬度的函數(shù),在非xhtml標準頁面下有可能有問題
*/
function getWidth()
{
var winWidth = '';
if (window.innerWidth)//for Firefox
{
winWidth = window.innerWidth;
}
else if((document.body) && (document.body.clientWidth))
{
winWidth = document.body.clientWidth;
}
if (document.documentElement && document.documentElement.clientWidth)
{
winWidth = document.documentElement.clientWidth;
}
return winWidth;
}
/**
* 獲取屏幕高度的函數(shù)
* html,body高度屬性必須設值為height:100%否則在火狐瀏覽器下獲取不到真實高度
*/
function getHeight()
{
var winHeight = '';
if (window.innerHeight)//for Firefox
{
winHeight = window.innerHeight;
}
else if((document.body) && (document.body.clientHeight))
{
winHeight = document.body.clientHeight;
}
if (document.documentElement && document.documentElement.clientHeight)
{
winHeight = document.documentElement.clientHeight;
}
return winHeight;
}
*:紅色部分為修改的位置或添加的代碼
修改部分:
1.增強型的獲取窗口長度和寬度的函數(shù);
2.在style.top,style.left等處在Firefox下必須使用單位px;
3.調(diào)整 Flash參數(shù)之wmodel,即window model,詳情請自己搜索;
修改以上幾處,就可以實現(xiàn)IE,F(xiàn)irefox的準確定位和相同的顯示效果。
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<html xmlns="http://www.w3.org/1999/xhtml ">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>無標題文檔</title>
<script language="javascript" type="text/javascript" src="flash.js"></script>
<style type="text/css">
body { height:1000px;width:100%}
.zhans_ship { width:250px; height:200px; Z-INDEX:99999; right: 0px; VISIBILITY: hidden; BORDER-BOTTOM: #000 2px solid; POSITION: absolute; BACKGROUND-COLOR: #000;top:378px;}
.top_ship { width:250px; height:26px; background-image:url(kkkk/msgTopBg.gif);font-family:"宋體"; font-size:12px; color:#FFFFFF;}
.top_ship div { width:150px; height:auto; float:left; line-height:20px;}
.bfq_a {font-size: 12px; background-image: url('kkkk/bomBg.gif');height:15px; line-height:15px; color: #ffffff;padding-top:2px; text-align:center;}
.bfq_a a:link { font-family:"宋體"; font-size:12px; text-decoration:none; color:#FFFFFF;}
.bfq_a a:visited { font-family:"宋體"; font-size:12px; text-decoration:none; color:#FFFFFF;}
.bfq_a a:active { font-family:"宋體"; font-size:12px; text-decoration:none; color:#FFFFFF;}
.bfq_a a:hover { font-family:"宋體"; font-size:12px; text-decoration:none; color:#FFFFFF;}
</style>
</head>
<body>
<div class="zhans_ship" id="eMeng">
<div class="top_ship"><div>視頻廣告:</div><span title=關閉 style="CURSOR: hand;color:white;font-size:12px;font-weight:bold;margin-right:4px; float:right; width:auto; height:auto; margin-top:3px;" onclick=closeDiv() >×</span></div>
<!-- flash 顯示部分 start -->
<div class="mid_ship">
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0 " width="250" height="150">
<param name="movie" value="player.swf">
<param name="quality" value="high">
<param name="allowFullScreen" value="true" />
<param name="FlashVars" value="vcastr_file=http://www.xxx.cn/zhaoshang.flv&vcastr_title=MiningGo&BarColor=0xFFffff&BarPosition=1&IsShowBar=3&BarTransparent=10&LogoText=Zgcjq.COM&IsAutoPlay=1&IsContinue=1" />
<embed src="player.swf" allowFullScreen="true" FlashVars="vcastr_file=http://www.xxx.com/images/zhaoshang.flv&vcastr_title=MiningGo&BarColor=0xFFffff&BarPosition=1&IsShowBar=3&BarTransparent=10&LogoText=Zgcjq.COM&IsAutoPlay=1&IsContinue=1" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer " wmode="transparent" type="application/x-shockwave-flash" width="250" height="150"></embed>
</object>
</div>
<!-- flash 顯示部分 end -->
<div class="bfq_a"><a href="#" target="_blank">大型XX活動</a></div>
</div>
</body>
</html>
flash.js代碼(修改后的)如下:
if(document.all){
window.attachEvent('onload',getMsg);
}else{
window.addEventListener('load',getMsg,false);
}
window.onresize = resizeDiv;
window.onerror = function(){}
var divTop,divLeft,divWidth,divHeight,docHeight,docWidth,objTimer,i = 0;
function getMsg()
{
try{
var eMeng = document.getElementById("eMeng");
/* 為修改前
var docWidth = document.documentElement.clientWidth;
var docHeight = document.documentElement.clientHeight;
*/
//修改后:
var docWidth = getWidth();
var docHeight = getHeight();
divTop = parseInt(eMeng.style.top,10);
divLeft = parseInt(eMeng.style.left,10);
divHeight = parseInt(eMeng.offsetHeight,10);
divWidth = parseInt(eMeng.offsetWidth,10);
eMeng.style.top = parseInt(document.documentElement.scrollTop,10) + docHeight + 10+"px" ;// divHeight
eMeng.style.left = parseInt(document.documentElement.scrollLeft,10) + docWidth - divWidth+"px" ;
eMeng.style.visibility = "visible";
objTimer = window.setInterval("moveDiv()",10)
}catch(e){
}
}
function resizeDiv()
{
i+=1;
try{
var eMeng = document.getElementById("eMeng");
var docWidth = getWidth();
var docHeight = getHeight();
divHeight = parseInt(eMeng.offsetHeight,10)
divWidth = parseInt(eMeng.offsetWidth,10)
eMeng.style.top = docHeight - divHeight + parseInt(document.documentElement.scrollTop,10)+"px" ;
eMeng.style.left = docWidth - divWidth + parseInt(document.documentElement.scrollLeft,10)+"px" ;
}catch(e){}
}
function moveDiv()
{
try
{
var eMeng = document.getElementById("eMeng");
var docWidth = getWidth();
var docHeight = getHeight();
divHeight = parseInt(eMeng.offsetHeight,10);
divWidth = parseInt(eMeng.offsetWidth,10);
if(parseInt(eMeng.style.top,10) <= (docHeight - divHeight + parseInt(document.documentElement.scrollTop,10)))
{
window.clearInterval(objTimer);
objTimer = window.setInterval("resizeDiv()",1);
}
divTop = parseInt(eMeng.style.top,10);
divTop--;
eMeng.style.top = divTop+"px" ;
}catch(e){
}
}
function closeDiv()
{
var eMeng = document.getElementById("eMeng");
eMeng.innerHTML='';
eMeng.style.visibility='hidden';
if(objTimer) window.clearInterval(objTimer);
}
/**
* 獲取屏幕寬度的函數(shù),在非xhtml標準頁面下有可能有問題
*/
function getWidth()
{
var winWidth = '';
if (window.innerWidth)//for Firefox
{
winWidth = window.innerWidth;
}
else if((document.body) && (document.body.clientWidth))
{
winWidth = document.body.clientWidth;
}
if (document.documentElement && document.documentElement.clientWidth)
{
winWidth = document.documentElement.clientWidth;
}
return winWidth;
}
/**
* 獲取屏幕高度的函數(shù)
* html,body高度屬性必須設值為height:100%否則在火狐瀏覽器下獲取不到真實高度
*/
function getHeight()
{
var winHeight = '';
if (window.innerHeight)//for Firefox
{
winHeight = window.innerHeight;
}
else if((document.body) && (document.body.clientHeight))
{
winHeight = document.body.clientHeight;
}
if (document.documentElement && document.documentElement.clientHeight)
{
winHeight = document.documentElement.clientHeight;
}
return winHeight;
}
*:紅色部分為修改的位置或添加的代碼
修改部分:
1.增強型的獲取窗口長度和寬度的函數(shù);
2.在style.top,style.left等處在Firefox下必須使用單位px;
3.調(diào)整 Flash參數(shù)之wmodel,即window model,詳情請自己搜索;
修改以上幾處,就可以實現(xiàn)IE,F(xiàn)irefox的準確定位和相同的顯示效果。
相關文章

flash如何制作形狀補間動畫?flash創(chuàng)建補間形狀技巧
flash一款功能強大的動畫制作軟件,制作動畫很非常的方便,但動畫過程使用的都是形狀補間功能。今天小編就來給大家介紹一下flash形狀補間動畫制作方法,感興趣的快來看看吧2022-05-11
flash cs6怎么做花朵成長的逐幀動畫?flash中想要繪制一個花開的動畫,該怎么畫出各個圖形然后做逐幀動畫呢?下面我們就來看看詳細的教程,需要的朋友可以參考下2021-03-09
Flash怎么將動畫復制為ActionScript3.0并使用?
Flash怎么將動畫復制為ActionScript3.0并使用?Flash中制作的動畫想要直接粘貼到另一個對象中,我們可以使用復制腳本代碼的方式復制動畫,下面我們就來看看詳細的教程,需2017-12-08
flash怎么制作漫畫人物行走的動畫?flash中想要制作一段行走的動畫,該怎么設計呢?下面我們就來看看詳細的教程,很簡單,需要的朋友可以參考下2017-04-18- 這篇教程是向腳本之家的朋友分享flash逐幀動畫制作全過程,教程非?;A,很適合新手來學習,推薦過來,有興趣的朋友可以過來學習2016-01-15
- 下面小編就為大家介紹利用Flash正確的口型吻合動畫技巧,教程很不錯,非常適合新手來學習,推薦到腳本之家,喜歡的朋友一起來學習吧2015-01-15
- 這篇教程是向腳本之家的朋友介紹Flash動畫制作技巧:圖形元件相關知識,教程很基礎,但很實用,推薦到腳本之家,喜歡的朋友可以過來學習一下,希望能對大家有所幫助2015-01-05
Flash動畫制作小黑人經(jīng)典動畫效果技巧介紹(圖文)
本教程是向大家介紹Flash動畫制作小黑人經(jīng)典動畫效果技巧,教程很經(jīng)典,介紹的非常詳細,相信對學習Flash朋友有一定的幫助。轉發(fā)過來,希望對大家有所幫助2014-08-05- 本教程是向大家介紹利用Flash制作旋轉的3D立體盒動畫教程,制作出來的效果非常好看,教程介紹的很詳細,希望大家通過本篇教程能學習Flash制作3D動畫的方法,這樣以后就可以2014-07-22
- 本教程向大家介紹了Flash cs3制作人物行走動畫技巧,并做了詳細的介紹,覺得教程很不錯,轉發(fā)過來,希望給朋友們帶來幫助2014-07-15




