首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > JavaScript >

大家帮忙,为什么出错,很急该怎么处理

2012-04-20 
大家帮忙,为什么出错,很急,,!DOCTYPEhtmlPUBLIC-//W3C//DTDXHTML1.0Transitional//EN http://www.w3.o

大家帮忙,为什么出错,很急,,
<!DOCTYPE   html   PUBLIC   "-//W3C//DTD   XHTML   1.0   Transitional//EN "   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<html   xmlns= "http://www.w3.org/1999/xhtml ">
<head>
<meta   http-equiv= "Content-Type "   content= "text/html;   charset=gb2312 "   />
<title> 无标题文档 </title>
<style   type= "text/css ">
<!--
.fontcolor   {color:   #0B3960}
body,td,th   {
font-size:   9pt;
color:   #2B4D8A;
}
body   {
margin-top:   200px;
}
.txt{
      width:140px;
      border:1px   solid   #447CB5;
      background-color:#EBF5FC;
}
li.msg{
      list-style:none;
      margin-left:0px;
      height:16px;
      padding-top:9px;
}
-->
</style>
<script   language= "javascript ">

      /*
        *   @   function:   single   line   scroll
*   @   author:Tom  
*   @   date:   2007-5-19
*/

      /*---------------------------------------*/
      function   Marquee(w,h)
      {
      this.container=null;
      this.msgBox_1=null;
      this.msgBox_2=null;
      this._w=w+ "px ";
      this._h=h+ "px ";
      this.msg_arr=[];
      this.msgString= " ";
      this.isGo=true;
      this.counter=0;
      }
     
      Marquee.prototype.push=function(obj)
      {
              this.msg_arr.push(obj);
      }
     
      Marquee.prototype.init=function()
      {
              for(var   i=0;i <this.msg_arr.length;i++)
      {
            this.msgString+= " <li   class=\ "msg\ "> "+this.msg_arr[i]+ " </li> ";      
      }
     
              this.container=document.createElement( "DIV ");     //初始化外层容器
      this.container.style.width=this._w;
      this.container.style.height=this._h;
      this.container.style.verticalAlign= "middle ";
      this.container.style.overflowY= "hidden ";
     
      this.msgBox_1=document.createElement( "DIV ");     //初始化内层容器
      this.msgBox_1.style.width=this._w;
      this.msgBox_1.style.verticalAlign= "middle ";
      this.msgBox_1.innerHTML=this.msgString;
     
      this.msgBox_2=document.createElement( "DIV ");
      this.msgBox_2.style.width=this._w;
      this.msgBox_2.style.verticalAlign= "middle ";


      this.msgBox_2.innerHTML=this.msgString;
     
      this.container.appendChild(this.msgBox_1);
      this.container.appendChild(this.msgBox_2);
     
      var   public=document.getElementById( "public ");
      public.appendChild(this.container);
      this.doScroll();
      }
     
      Marquee.prototype.doScroll=function()
      {
              if(this.isGo)
      {
              if(this.counter   %   50   > =   25)
      {
                    if(this.container.scrollTop-this.msgBox_1.offsetHeight> 0)
            {
                    this.container.scrollTop-=this.msgBox_1.offsetHeight;
            }
                    this.container.scrollTop++;
      }
      this.counter++;
      setTimeout(this.doScroll(),100);
      }
      }
     
      Marquee.prototype.start=function()
      {
            this.isGo=true;
      }
     
      Marquee.prototype.stop=function()
      {
            this.isGo=false;
      }
     
      window.onload=function()
      {
              var   m=new   Marquee(150,25);
      m.push( "aaaaaaaaaaaaaaaaaaaaaaaaa ");
      m.push( "bbbbbbbbbbbbbbbbbbbbbbbbb ");
      m.push( "ccccccccccccccccccccccccc ");
      m.init();
      }
</script>
</head>

<body>
<table   width= "40% "   border= "0 "   align= "center "   cellpadding= "0 "   cellspacing= "0 "   bgcolor= "#5992DD "   style= "border:1px   solid   #1156BD ">
    <tr>
        <td   width= "48% "   height= "25 "   bgcolor= "#B5CEF0 "> <strong> &nbsp;   <span   class= "fontcolor "> 登录聊天室   </span> </strong>                 </td>
        <td   width= "52% "   valign= "middle "   bgcolor= "#B5CEF0 "> <div   id= "public "   style= "float:right;   vertical-align:middle; "> </div> </td>
    </tr>
    <tr>
        <td   colspan= "2 "> <table   width= "100% "   border= "0 "   cellpadding= "0 "   cellspacing= "1 "   bgcolor= "#FFFFFF ">
            <tr>


                <td   width= "23% "   height= "25 "   align= "center "   bgcolor= "#DAEAF8 "> 昵称 </td>
                <td   width= "77% "   bgcolor= "#DAEAF8 "> &nbsp;
                            <input   name= "nickname "   type= "text "   class= "txt "   />
                    &nbsp; <span   id= "nickmsg "> <font   color=red> (*必填) </font> </span>   </td>
            </tr>
            <tr>
                <td   height= "25 "   align= "center "   bgcolor= "#DAEAF8 "> 密码 </td>
                <td   height= "25 "   bgcolor= "#DAEAF8 "> &nbsp;
                            <input   name= "password "   type= "text "   class= "txt "   />
                    &nbsp; <span   id= "pwdmsg "> <font   color=red> (*必填) </font> </span>   </td>
            </tr>
        </table> </td>
    </tr>
    <tr>
        <td   height= "30 "   colspan= "2 "   align= "center "   bgcolor= "#FFFFFF "> <input   type= "submit "   name= "Submit "   value= "提交 "   />
            &nbsp;&nbsp;&nbsp;
            <input   type= "button "   name= "Submit2 "   value= "取消 "   />
            &nbsp;&nbsp;&nbsp;   </td>
    </tr>
</table>
</body>
</html>


[解决办法]
应该是循环调用后到导致内存溢出!

改了改,可以用了!

L@_@K


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN " "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<html xmlns= "http://www.w3.org/1999/xhtml ">
<head>
<meta http-equiv= "Content-Type " content= "text/html; charset=gb2312 " />
<title> 无标题文档 </title>
<style type= "text/css ">
<!--
.fontcolor {color: #0B3960}
body,td,th {
font-size: 9pt;
color: #2B4D8A;
}
body {
margin-top: 200px;
}
.txt{
width:140px;
border:1px solid #447CB5;
background-color:#EBF5FC;
}
li.msg{
list-style:none;
margin-left:0px;
height:16px;
padding-top:9px;
}
-->
</style>
<script language= "javascript ">

/*
* @ function: single line scroll
* @ author:Tom
* @ date: 2007-5-19


*/

/*---------------------------------------*/
function Marquee(w,h)
{
this.container=null;
this.msgBox_1=null;
this.msgBox_2=null;
this._w=w+ "px ";
this._h=h+ "px ";
this.msg_arr=[];
this.msgString= " ";
this.isGo=true;
this.counter=0;
}

Marquee.prototype.push=function(obj)
{
this.msg_arr.push(obj);
}

Marquee.prototype.init=function()
{
for(var i=0;i <this.msg_arr.length;i++)
{
this.msgString+= " <li class=\ "msg\ "> "+this.msg_arr[i]+ " </li> ";
}

this.container=document.createElement( "DIV "); //初始化外层容器
this.container.style.width=this._w;
this.container.style.height=this._h;
this.container.style.verticalAlign= "middle ";
this.container.style.overflowY= "hidden ";

this.msgBox_1=document.createElement( "DIV "); //初始化内层容器
this.msgBox_1.style.width=this._w;
this.msgBox_1.style.verticalAlign= "middle ";
this.msgBox_1.innerHTML=this.msgString;

this.msgBox_2=document.createElement( "DIV ");
this.msgBox_2.style.width=this._w;
this.msgBox_2.style.verticalAlign= "middle ";
this.msgBox_2.innerHTML=this.msgString;

this.container.appendChild(this.msgBox_1);
this.container.appendChild(this.msgBox_2);

var public=document.getElementById( "public ");
public.appendChild(this.container);
}

var marquee;
function fnDoScroll()
{
with(marquee)
{
if(isGo)
{
if(counter % 50 > = 25)
{
if(container.scrollTop-msgBox_1.offsetHeight> 0)
{
container.scrollTop-=msgBox_1.offsetHeight;
}
container.scrollTop++;
}
counter++;
}
}
}

Marquee.prototype.start=function()
{
this.isGo=true;
}

Marquee.prototype.stop=function()
{
this.isGo=false;
}

window.onload=function()
{
var m=new Marquee(150,25);
m.push( "aaaaaaaaaaaaaaaaaaaaaaaaa ");
m.push( "bbbbbbbbbbbbbbbbbbbbbbbbb ");
m.push( "ccccccccccccccccccccccccc ");
m.init();
marquee = m;
window.setInterval(fnDoScroll, 100);
}
</script>
</head>

<body>
<table width= "40% " border= "0 " align= "center " cellpadding= "0 " cellspacing= "0 " bgcolor= "#5992DD " style= "border:1px solid #1156BD ">
<tr>
<td width= "48% " height= "25 " bgcolor= "#B5CEF0 "> <strong> &nbsp; <span class= "fontcolor "> 登录聊天室 </span> </strong> </td>
<td width= "52% " valign= "middle " bgcolor= "#B5CEF0 "> <div id= "public " style= "float:right; vertical-align:middle; "> </div> </td>
</tr>
<tr>
<td colspan= "2 "> <table width= "100% " border= "0 " cellpadding= "0 " cellspacing= "1 " bgcolor= "#FFFFFF ">


<tr>
<td width= "23% " height= "25 " align= "center " bgcolor= "#DAEAF8 "> 昵称 </td>
<td width= "77% " bgcolor= "#DAEAF8 "> &nbsp;
<input name= "nickname " type= "text " class= "txt " />
&nbsp; <span id= "nickmsg "> <font color=red> (*必填) </font> </span> </td>
</tr>
<tr>
<td height= "25 " align= "center " bgcolor= "#DAEAF8 "> 密码 </td>
<td height= "25 " bgcolor= "#DAEAF8 "> &nbsp;
<input name= "password " type= "text " class= "txt " />
&nbsp; <span id= "pwdmsg "> <font color=red> (*必填) </font> </span> </td>
</tr>
</table> </td>
</tr>
<tr>
<td height= "30 " colspan= "2 " align= "center " bgcolor= "#FFFFFF "> <input type= "submit " name= "Submit " value= "提交 " />
&nbsp;&nbsp;&nbsp;
<input type= "button " name= "Submit2 " value= "取消 " />
&nbsp;&nbsp;&nbsp; </td>
</tr>
</table>
</body>
</html>

热点排行