日期:2014-05-16  浏览次数:20494 次

文字移动效果不能使用
为什么我的文字移动效果不能使用,我在里面加了两个alert进行调试,发现只有第一个alert能运行,第二个alert就运行不了,怀疑是document对象的问题,但找了半天都找不出问题来!高手帮我看看呀!!
<html>
  <head>
  <title>文字移动效果</title>
  </head>
  <body>
  <p>
  <center>
  <font color="ffaafa"><h2>文字移动效果----上下滚动的文本</h2></font>
  <hr width=300>
  <p>
  <script lanuage="JavaScript">
  var MarqueeWidth=180;
  var MarqueeHeight=80;
  var speed=3;
  var marqueencontents='<font face="Arial" color=#993366><strong><big>kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk</big></strong></font>';
if(document.all)
{
alert("11111"); //第一个alert能运行
document.write('<marquee direction="up" scrollAmount='+speed+' stytle="width:'+MarqueeWidth+';height:'+MarqueeHeight+'">'+marqueecontents+'</marquee>');
alert("22222"); //第二个alert就不能运行了
}
function regenerate()
{
if(document.layers)
{
setTimeout("window.onresize=regenerate",450);
intializemarquee();
}
}

function intializemarquee()
{
document.MarqueeMessage001.doucument.MarqueeMessage002.document.write(marqueecontests);
document.MarqueeMessage001.doucument.MarqueeMessage002.document.close;
thelength=document.MarqueeMessage001.doucument.MarqueeMessage002.document.height;
scrollText();
}

function scrollText()
{
if(document.MarqueeMessage001.doucument.MarqueeMessage002.top>=thelength*(-1))
{
document.MarqueeMessage001.doucument.MarqueeMessage002.top-=speed;
setTimeout("ScrollText()",100);
}
else
{
document.MarqueeMessage001.doucument.MarqueeMessage002.top=MarqueeHeight;
ScrollText();
}
}
window.onload=regenerate;
</script>
<ilayer name="MarqueeMessage001" width=&{MarqueeWidth};height=&{MarqueeHeight};>
<layer name="MarqueeMessage002" width=&{MarqueeWidth};height=&{MarqueeHeight};>
</ilayer>
</body>
</html>

------解决方案--------------------
var marqueencontents= ' <font face="Arial" color=#993366 > <strong > <big >kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk </big > </strong > </font > '; 

if(document.all) 

alert("11111"); //第一个alert能运行 
document.write( ' <marquee direction="up" scrollAmount= '+speed+ ' stytle="width: '+MarqueeWidth+ ';height: '+MarqueeHeight+ '" > '+marqueecontents+ ' </marquee > '); 
alert("22222"); //第二个alert就不能运行了 
}

=================================== 
請比較一下紅色標記部分.