我有以下用于show running line的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中运行? 感谢
答案 0 :(得分:2)
您的代码包含行if (document.all)
,因此Marquee只会写入IE中的文档。
我删除了这一行,它似乎可以在Firefox中使用。我在这台机器上没有Chrome进行测试。
答案 1 :(得分:2)
document.write()
document.all
<marquee>
setTimeout
函数怀旧......就像是1998年。