我有以下 JavaScript 用于显示运行线:
<script type="text/javascript" language="javascript">
//Change script's width (in pixels)
var marqueewidth=800
//Change script's height (in pixels, pertains only to NS)
var marqueeheight=20
//Change script's scroll speed (larger is faster)
var speed=3
//Change script's contents
var marqueecontents='You text here'
if (document.all)
document.write('<marquee scrollAmount='+speed+' style="width:'+marqueewidth+'">'+marqueecontents+'</marquee>')
function regenerate(){
window.location.reload()
}
function regenerate2(){
if (document.layers){
setTimeout("window.onresize=regenerate",450)
intializemarquee()
}
}
function intializemarquee(){
document.cmarquee01.document.cmarquee02.document.write('<nobr>'+marqueecontents+'</nobr>')
document.cmarquee01.document.cmarquee02.document.close()
thelength=document.cmarquee01.document.cmarquee02.document.width
scrollit()
}
function scrollit(){
if (document.cmarquee01.document.cmarquee02.left>=thelength*(-1)){
document.cmarquee01.document.cmarquee02.left-=speed
setTimeout("scrollit()",100)
}
else{
document.cmarquee01.document.cmarquee02.left=marqueewidth
scrollit()
}
}
window.onload=regenerate2
</script>
我应该在脚本中更改哪些内容才能使其在 FF 和 Chrome 中工作? 谢谢
最佳答案
您的代码包含行 if (document.all)
,因此选取框只会写入 IE 中的文档。
我已经删除了这一行,它似乎可以在 Firefox 中使用。我的机器上没有 Chrome 来测试。
关于javascript - 脚本仅适用于 IE,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2795832/