Flash 视频广告的定位兼容性问题

在项目中,用到了一个Flash视频广告,但是该视频广告在Firefox中显示实在是差强人意,居然漂浮在了网站的左上角,该怎么解决这个问题呢?

调用代码如下:




无标题文档





视频广告:
×
















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);
}
/**
* 获取屏幕宽度的函数,在非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;
}
/**
* 获取屏幕高度的函数
* 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.增强型的获取窗口长度和宽度的函数;
2.在style.top,style.left等处在Firefox下必须使用单位px;
3.调整 Flash参数之wmodel,即window model,详情请自己搜索;
修改以上几处,就可以实现IE,Firefox的准确定位和相同的显示效果。

以上就是Flash 视频广告的定位兼容性问题的详细内容,更多请关注0133技术站其它相关文章!

赞(0) 打赏
未经允许不得转载:0133技术站首页 » Flash教程