2010-05-08 30 views
0

工作,我有以下的JavaScript顯示行駛路線:腳本只能在IE

<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

你是什麼意思的「顯示運行線」?你知道你的代碼在哪裏出了問題嗎?請更具體一些。 – 2010-05-08 22:16:43

+0

它應該在位於網站頂部的表格中顯示正在運行的字符串。它在IE中正常工作,但在Chrome和FF中它什麼也沒有顯示。它不會給出任何錯誤。 – Alexan 2010-05-08 22:23:25

回答

2

您的代碼包含if (document.all)行,所以Marquee只會被寫入到IE中的文檔中。

我刪除了這一行,它似乎在Firefox中工作。我沒有在這臺機器上測試Chrome。

+0

再加上「initializemarquee」函數看起來很奇怪。 – Pointy 2010-05-08 22:36:48

+0

謝謝,我評論(document.all)是否現在可以工作。 – Alexan 2010-05-08 22:44:46

2
  1. 缺少分號
  2. document.write()
  3. document.all
  4. <marquee>
  5. 全局
  6. 字符串作爲setTimeout功能
  7. 無壓痕

懷舊......它就像是1998年。