解决javascript不兼容除IE外其他浏览器问题
今天,老迈体我措置一个网站的兼容问题,一般兼容性问题是兼容其他浏览器,就IE不兼容,而这个有点非凡,只兼容IE,不兼容其他浏览器。初步不雅察看往后,我发现是Javacript的问题。而不关div和css什么工作。
setInterval(“scrollUp1()”,10);//?
这其实就是很通俗的轮播。而造成不兼容的问题就是因为代码写的不完美,下面我给出我的解决方案:
<SCRIPT language=JavaScript>这是原本的代码:
<SCRIPT language=JavaScript>
var marquees=document.getElementById(“flash”);
if(preTop==flash.scrollTop){
flash.noWrap=true;
stopscroll=false;本文地址:http://www.zhuojie.net/?/20120706.html
style.width=235;
style.height=marqueesHeight;
style.overflowX=”visible”;
document.body.onload=init1;
marqueesHeight=550;
noWrap=true;
onmouseover=new Function(“stopscroll=true”);
}
</SCRIPT>
onmouseout=new Function(“stopscroll=false”);
}preTop=0; currentTop=0;
function init1(){
templayer1.innerHTML=”";
setInterval(“scrollUp1()”,20);//?
while(templayer1.offsetHeight<marqueesHeight){
templayer1.innerHTML+=flash.innerHTML;
flash.innerHTML=templayer1.innerHTML+templayer1.innerHTML;function scrollUp1(){
flash.style.overflowX=”visible”;
if(stopscroll==true) return;
preTop=flash.scrollTop;
flash.scrollTop=templayer1.offsetHeight-marqueesHeight;
flash.scrollTop+=1;
}
marqueesHeight=550;感谢感动 胡小易 的投稿
var templayer=document.getElementById(“templayer1″);
with(flash){
templayer1.innerHTML=”";
flash.style.overflowY=”hidden”;
flash.onmouseover=new Function(“stopscroll=true”);with(flash){
flash.onmouseout=new Function(“stopscroll=false”);
}
document.write(‘<div id=”templayer1″ style=”position:absolute;z-index:1;visibility:hidden;top:6px;”></div>’);
function init1(){
templayer1.innerHTML+=flash.innerHTML;
}
while(templayer1.offsetHeight<marqueesHeight){
flash.innerHTML=templayer1.innerHTML+templayer1.innerHTML;
}
flash.scrollTop+=1;
window.onload=init1;
function scrollUp1(){
if(stopscroll==true) return;
preTop=flash.scrollTop;
flash.scrollTop+=1;
}
document.write(‘<div id=”templayer1″ style=”position:absolute;z-index:1;visibility:hidden;top:6px;”></div>’);
if(preTop==flash.scrollTop){
flash.scrollTop=templayer1.offsetHeight-marqueesHeight;
var preTop=0; currentTop=0;
flash.scrollTop+=1;
flash.style.width=235+”px”;
flash.style.height=marqueesHeight+”px”;
}
}
}
</SCRIPT>
stopscroll=false;
将代码写完美,不仅仅会更兼容,也会更读假爆我们写轨范,万万不要妄想一时的快速,我们要写出好轨范,万万不能呈现如尚罾υ题。
style.overflowY=”hidden”;
除非注明,胡小易博客文章均为原创,转载请以链接形式标明本文地址
本页关键词:
上一篇:经由过程团队、产物、市场三点来谈谈团队打点 下一篇:分享这几个月工作的经验和技巧