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

  发布时间:2009-09-13 21:23:53   作者:佚名   我要评论
在项目中,用到了一个Flash视频广告,但是该视频广告在Firefox中显示实在是差强人意,居然漂浮在了网站的左上角,该怎么解决这个问题呢?
(福利推荐:【腾讯云】服务器最新限时优惠活动,云服务器1核2G仅99元/年、2核4G仅768元/3年,立即抢购>>>:9i0i.cn/qcloud

(福利推荐:你还在原价购买阿里云服务器?现在阿里云0.8折限时抢购活动来啦!4核8G企业云服务器仅2998元/3年,立即抢购>>>:9i0i.cn/aliyun

调用代码如下:
<!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(?flash/skill/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('?flash/skill/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);
}
/**
* 获取屏幕宽度的函数,在非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如何制作形状补间动画?flash创建补间形状技巧

    flash一款功能强大的动画制作软件,制作动画很非常的方便,但动画过程使用的都是形状补间功能。今天小编就来给大家介绍一下flash形状补间动画制作方法,感兴趣的快来看看吧
    2022-05-11
  • flash cs6怎么做花朵成长的逐帧动画?

    flash cs6怎么做花朵成长的逐帧动画?flash中想要绘制一个花开的动画,该怎么画出各个图形然后做逐帧动画呢?下面我们就来看看详细的教程,需要的朋友可以参考下
    2021-03-09
  • Flash怎么将动画复制为ActionScript3.0并使用?

    Flash怎么将动画复制为ActionScript3.0并使用?Flash中制作的动画想要直接粘贴到另一个对象中,我们可以使用复制脚本代码的方式复制动画,下面我们就来看看详细的教程,需
    2017-12-08
  • flash怎么制作漫画人物行走的动画?

    flash怎么制作漫画人物行走的动画?flash中想要制作一段行走的动画,该怎么设计呢?下面我们就来看看详细的教程,很简单,需要的朋友可以参考下
    2017-04-18
  • flash逐帧动画制作全过程解析

    这篇教程是向程序员之家的朋友分享flash逐帧动画制作全过程,教程非常基础,很适合新手来学习,推荐过来,有兴趣的朋友可以过来学习
    2016-01-15
  • Flash正确的口型吻合动画技巧

    下面小编就为大家介绍利用Flash正确的口型吻合动画技巧,教程很不错,非常适合新手来学习,推荐到程序员之家,喜欢的朋友一起来学习吧
    2015-01-15
  • Flash动画制作技巧 图形元件相关知识介绍

    这篇教程是向程序员之家的朋友介绍Flash动画制作技巧:图形元件相关知识,教程很基础,但很实用,推荐到程序员之家,喜欢的朋友可以过来学习一下,希望能对大家有所帮助
    2015-01-05
  • Flash动画制作小黑人经典动画效果技巧介绍(图文)

    本教程是向大家介绍Flash动画制作小黑人经典动画效果技巧,教程很经典,介绍的非常详细,相信对学习Flash朋友有一定的帮助。转发过来,希望对大家有所帮助
    2014-08-05
  • Flash制作旋转的3D立体盒动画教程

    本教程是向大家介绍利用Flash制作旋转的3D立体盒动画教程,制作出来的效果非常好看,教程介绍的很详细,希望大家通过本篇教程能学习Flash制作3D动画的方法,这样以后就可以
    2014-07-22
  • Flash cs3制作人物行走动画技巧图文解析

    本教程向大家介绍了Flash cs3制作人物行走动画技巧,并做了详细的介绍,觉得教程很不错,转发过来,希望给朋友们带来帮助
    2014-07-15

最新评论

?


http://www.vxiaotou.com