javascript 对联广告 修改兼容火狐
如下对联广告代码,应该跟随页面滚动而滚动,IE没有问题,火狐不滚动,应该怎么修改?suspendcode="<DIVid=lovexin1style='Z-INDEX:1...
如下对联广告代码,应该跟随页面滚动而滚动,IE没有问题,火狐不滚动,应该怎么修改?
suspendcode="<DIV id=lovexin1 style='Z-INDEX: 10; LEFT: 6px; POSITION: absolute; TOP: 200px; width: 100; height: 300px;'><img src='/images/close.gif' onClick='javascript:window.hide()' width='100' height='14' border='0' vspace='3' alt='关闭对联广告'><a href='/newhouse/d-766.html' target='_blank'><img src='/templets/anleyeimg/2-01.gif' width='100' height='300' border='0'></a></DIV>"
document.write(suspendcode);
suspendcode="<DIV id=lovexin2 style='Z-INDEX: 10; right:6px; POSITION: absolute; TOP: 200px; width: 100; height: 300px;'><img src='/images/close.gif' onClick='javascript:window.hide()' width='100' height='14' border='0' vspace='3' alt='关闭对联广告'><a href='/newhouse/d-766.html' target='_blank'><img src='/templets/anleyeimg/2-01.gif' width='100' height='300' border='0'></a></DIV>"
document.write(suspendcode);
//flash格式调用方法
//<EMBED src='flash.swf' quality=high WIDTH=100 HEIGHT=300 TYPE='application/x-shockwave-flash' id=ad wmode=opaque></EMBED>
var DTD = document.compatMode == "CSS1Compat" ? document.documentElement : document.body;
lastScrollY=0;
function heartBeat(){
diffY=DTD.scrollTop;
percent=.3*(diffY-lastScrollY);
if(percent>0)percent=Math.ceil(percent);
else percent=Math.floor(percent);
document.getElementById("lovexin1").style.pixelTop+=percent;
document.getElementById("lovexin2").style.pixelTop+=percent;
lastScrollY=lastScrollY+percent;
}
function hide()
{
document.getElementById("lovexin1").style.visibility="hidden";
document.getElementById("lovexin2").style.visibility="hidden";
}
window.setInterval("heartBeat()",1); 展开
suspendcode="<DIV id=lovexin1 style='Z-INDEX: 10; LEFT: 6px; POSITION: absolute; TOP: 200px; width: 100; height: 300px;'><img src='/images/close.gif' onClick='javascript:window.hide()' width='100' height='14' border='0' vspace='3' alt='关闭对联广告'><a href='/newhouse/d-766.html' target='_blank'><img src='/templets/anleyeimg/2-01.gif' width='100' height='300' border='0'></a></DIV>"
document.write(suspendcode);
suspendcode="<DIV id=lovexin2 style='Z-INDEX: 10; right:6px; POSITION: absolute; TOP: 200px; width: 100; height: 300px;'><img src='/images/close.gif' onClick='javascript:window.hide()' width='100' height='14' border='0' vspace='3' alt='关闭对联广告'><a href='/newhouse/d-766.html' target='_blank'><img src='/templets/anleyeimg/2-01.gif' width='100' height='300' border='0'></a></DIV>"
document.write(suspendcode);
//flash格式调用方法
//<EMBED src='flash.swf' quality=high WIDTH=100 HEIGHT=300 TYPE='application/x-shockwave-flash' id=ad wmode=opaque></EMBED>
var DTD = document.compatMode == "CSS1Compat" ? document.documentElement : document.body;
lastScrollY=0;
function heartBeat(){
diffY=DTD.scrollTop;
percent=.3*(diffY-lastScrollY);
if(percent>0)percent=Math.ceil(percent);
else percent=Math.floor(percent);
document.getElementById("lovexin1").style.pixelTop+=percent;
document.getElementById("lovexin2").style.pixelTop+=percent;
lastScrollY=lastScrollY+percent;
}
function hide()
{
document.getElementById("lovexin1").style.visibility="hidden";
document.getElementById("lovexin2").style.visibility="hidden";
}
window.setInterval("heartBeat()",1); 展开
4个回答
展开全部
火狐不支持pixelTop属性,好像也不支持 0.3的 .3 写法, 下面的代码在火狐12和IE8下通过调试。
<body>
<div style="height:2000px;" ></div>
</body>
<script type="text/javascript">
suspendcode="<DIV id=lovexin1 style='Z-INDEX: 10; LEFT: 6px; POSITION: absolute; TOP: 200px; width: 100; height: 300px;'><img src='/images/close.gif' onClick='javascript:window.hide()' width='100' height='14' border='0' vspace='3' alt='关闭对联广告'><a href='/newhouse/d-766.html' target='_blank'><img src='/templets/anleyeimg/2-01.gif' width='100' height='300' border='0'></a></DIV>"
document.write(suspendcode);
suspendcode="<DIV id=lovexin2 style='Z-INDEX: 10; right:6px; POSITION: absolute; TOP: 200px; width: 100; height: 300px;'><img src='/images/close.gif' onClick='javascript:window.hide()' width='100' height='14' border='0' vspace='3' alt='关闭对联广告'><a href='/newhouse/d-766.html' target='_blank'><img src='/templets/anleyeimg/2-01.gif' width='100' height='300' border='0'></a></DIV>"
document.write(suspendcode);
//flash格式调用方法
//<EMBED src='flash.swf' quality=high WIDTH=100 HEIGHT=300 TYPE='application/x-shockwave-flash' id=ad wmode=opaque></EMBED>
var DTD = document.compatMode == "CSS1Compat" ? document.documentElement : document.body;
lastScrollY=0;
function heartBeat(){
diffY=DTD.scrollTop;
percent=0.3*(diffY-lastScrollY); //0.3
if(percent>0)percent=Math.ceil(percent);
else percent=Math.floor(percent);
document.getElementById("lovexin1").style.top=parseInt(document.getElementById("lovexin1").style.top)+percent;
document.getElementById("lovexin2").style.top=parseInt(document.getElementById("lovexin2").style.top)+percent;
lastScrollY=lastScrollY+percent;
}
function hide()
{
document.getElementById("lovexin1").style.visibility="hidden";
document.getElementById("lovexin2").style.visibility="hidden";
}
window.setInterval("heartBeat()",1);
</script>
<body>
<div style="height:2000px;" ></div>
</body>
<script type="text/javascript">
suspendcode="<DIV id=lovexin1 style='Z-INDEX: 10; LEFT: 6px; POSITION: absolute; TOP: 200px; width: 100; height: 300px;'><img src='/images/close.gif' onClick='javascript:window.hide()' width='100' height='14' border='0' vspace='3' alt='关闭对联广告'><a href='/newhouse/d-766.html' target='_blank'><img src='/templets/anleyeimg/2-01.gif' width='100' height='300' border='0'></a></DIV>"
document.write(suspendcode);
suspendcode="<DIV id=lovexin2 style='Z-INDEX: 10; right:6px; POSITION: absolute; TOP: 200px; width: 100; height: 300px;'><img src='/images/close.gif' onClick='javascript:window.hide()' width='100' height='14' border='0' vspace='3' alt='关闭对联广告'><a href='/newhouse/d-766.html' target='_blank'><img src='/templets/anleyeimg/2-01.gif' width='100' height='300' border='0'></a></DIV>"
document.write(suspendcode);
//flash格式调用方法
//<EMBED src='flash.swf' quality=high WIDTH=100 HEIGHT=300 TYPE='application/x-shockwave-flash' id=ad wmode=opaque></EMBED>
var DTD = document.compatMode == "CSS1Compat" ? document.documentElement : document.body;
lastScrollY=0;
function heartBeat(){
diffY=DTD.scrollTop;
percent=0.3*(diffY-lastScrollY); //0.3
if(percent>0)percent=Math.ceil(percent);
else percent=Math.floor(percent);
document.getElementById("lovexin1").style.top=parseInt(document.getElementById("lovexin1").style.top)+percent;
document.getElementById("lovexin2").style.top=parseInt(document.getElementById("lovexin2").style.top)+percent;
lastScrollY=lastScrollY+percent;
}
function hide()
{
document.getElementById("lovexin1").style.visibility="hidden";
document.getElementById("lovexin2").style.visibility="hidden";
}
window.setInterval("heartBeat()",1);
</script>
展开全部
您好!很高兴为您答疑!
火狐不支持设置pixelTop和pixelLeft,您可以用top和left来代替。火狐下您可以安装Firebug检查页面代码,错误部分会有高亮提示。
您可以在火狐社区了解更多内容。希望我的回答对您有所帮助,如有疑问,欢迎继续在本平台咨询。
火狐不支持设置pixelTop和pixelLeft,您可以用top和left来代替。火狐下您可以安装Firebug检查页面代码,错误部分会有高亮提示。
您可以在火狐社区了解更多内容。希望我的回答对您有所帮助,如有疑问,欢迎继续在本平台咨询。
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
js浮动广告特效代码插件及开发使用文档:
源代码:
function HangAd(attr,parent)
{
this.Attr=attr;
this.ParentNode=parent;
this.ID=attr.id;
this.ShowState=false;
}
HangAd.prototype.Show=function(innerHTML)
{
if(this.ShowState) this.Hide();
var style="position:fixed;z-index:10000;";
if(this.Attr.top)
{
style+="top:"+this.Attr.top+";";
}
if(this.Attr.right)
{
style+="right:"+this.Attr.right+";";
}
if(this.Attr.left)
{
style+="left:"+this.Attr.left+";";
}
if(this.Attr.bottom)
{
style+="bottom:"+this.Attr.bottom+";";
}
if(this.Attr.width)
{
style+="width:"+this.Attr.width+";";
}
if(this.Attr.height)
{
style+="height:"+this.Attr.height+";";
}
var parentObj=document.getElementById(this.ParentNode);
if(!parentObj) parentObj=document.getElementsByTagName(this.ParentNode)[0];
var div=document.createElement("div");
div.setAttribute("id",this.ID);
div.setAttribute("style",style);
div.innerHTML=innerHTML;
parentObj.appendChild(div);
this.ShowState=true;
}
HangAd.prototype.Hide=function()
{
if(!this.ShowState) return;
var parentObj=document.getElementById(this.ParentNode);
if(!parentObj) parentObj=document.getElementsByTagName(this.ParentNode)[0];
var div=document.getElementById(this.ID);
parentObj.removeChild(div);
this.ShowState=false;
}
使用说明,详见:
www.
wpfworld.com/html/JavaScript/jsgongnenchajian/2012/0503/10.html
源代码:
function HangAd(attr,parent)
{
this.Attr=attr;
this.ParentNode=parent;
this.ID=attr.id;
this.ShowState=false;
}
HangAd.prototype.Show=function(innerHTML)
{
if(this.ShowState) this.Hide();
var style="position:fixed;z-index:10000;";
if(this.Attr.top)
{
style+="top:"+this.Attr.top+";";
}
if(this.Attr.right)
{
style+="right:"+this.Attr.right+";";
}
if(this.Attr.left)
{
style+="left:"+this.Attr.left+";";
}
if(this.Attr.bottom)
{
style+="bottom:"+this.Attr.bottom+";";
}
if(this.Attr.width)
{
style+="width:"+this.Attr.width+";";
}
if(this.Attr.height)
{
style+="height:"+this.Attr.height+";";
}
var parentObj=document.getElementById(this.ParentNode);
if(!parentObj) parentObj=document.getElementsByTagName(this.ParentNode)[0];
var div=document.createElement("div");
div.setAttribute("id",this.ID);
div.setAttribute("style",style);
div.innerHTML=innerHTML;
parentObj.appendChild(div);
this.ShowState=true;
}
HangAd.prototype.Hide=function()
{
if(!this.ShowState) return;
var parentObj=document.getElementById(this.ParentNode);
if(!parentObj) parentObj=document.getElementsByTagName(this.ParentNode)[0];
var div=document.getElementById(this.ID);
parentObj.removeChild(div);
this.ShowState=false;
}
使用说明,详见:
www.
wpfworld.com/html/JavaScript/jsgongnenchajian/2012/0503/10.html
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
给出完整代码,包括静态页面。我帮你调调。arthur.dong@gmail.com.
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询