今天调试了一个javascript程序 前天晚上弄都是好的。第二天一上班 就发现那个程序运行错误。然后调了半天,没有用。于是吃饭。结果回来的时候它莫名其妙的又好了。真是匪夷所思。是不是大家都会遇到这种问题啊?

解决方案 »

  1.   

    但就算写的不是很严格,也不会一会儿对,一会儿不对啊?而且写法都是按照xhtml格式写的。
      

  2.   

    我能再问一个问题吗?
    <html>
    <head>
    <title>左右滚动的图片效果 - 51windows.Net</title>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    </head>
    <body bgcolor="#999999"><table border="1" width="760" align="center">
    <tr>
    <td width="215"> </td>
    <td width="545">
    <!-- 滚动代码 begin -->
    <div id="demo" style="overflow:hidden;height:120px;width:543px;">
    <table width="100%" cellspacing="0">
    <tr>
    <td id="demo1">
    <table cellspacing="0" cellspacing="2">
    <tr>
    <td><a href="http://www.51windows.net/mypic/sight/page_01.htm" target="_blank"><img src="http://www.51windows.net/51wfolder_1/jsimg/TN_Feng016.JPG" border="0"/></a></td>
    <td><a href="http://www.51windows.net/mypic/sight/page_01.htm" target="_blank"><img src="http://www.51windows.net/51wfolder_1/jsimg/TN_Feng017.JPG" border="0"/></a></td>
    <td><a href="http://www.51windows.net/mypic/sight/page_01.htm" target="_blank"><img src="http://www.51windows.net/51wfolder_1/jsimg/TN_Feng018.JPG" border="0"/></a></td>
    <td><a href="http://www.51windows.net/mypic/sight/page_01.htm" target="_blank"><img src="http://www.51windows.net/51wfolder_1/jsimg/TN_Feng019.JPG" border="0"/></a></td>
    <td><a href="http://www.51windows.net/mypic/sight/page_01.htm" target="_blank"><img src="http://www.51windows.net/51wfolder_1/jsimg/TN_Feng020.JPG" border="0"/></a></td>
    <td><a href="http://www.51windows.net/mypic/sight/page_01.htm" target="_blank"><img src="http://www.51windows.net/51wfolder_1/jsimg/TN_Feng021.JPG" border="0"/></a></td>
    </tr>
    </table>
    </td>
    <td id="demo2"></td>
    </tr>
    </table>
    </div>
    <!-- 滚动代码 end -->
    </td>
    </tr>
    </table>
    <script>
    var speed=50
    demo2.innerHTML=demo1.innerHTML
    function Marquee(direct,MainId,contentId,copyId){
    var objMain = document.getElementById(MainId);
    var objContent = document.getElementById(contentId);
    var objCopy = document.getElementById(copyId);
    var mainWidth = objMain.offsetWidth
    var contentWidth = objContent.offsetWidth
    var copyWidth = objCopy.offsetWidth;
    var mainHeight = objMain.offsetHeight;
    var contentHeight = objContent.offsetHeight;
    var copyHeight = objCopy.offsetHeight;
    if (direct=="LEFT"){
    if (copyWidth-objMain.scrollLeft<=0){
    objMain.scrollLeft-=contentWidth;
    }else{
    objMain.scrollLeft+=2;
    }
    }else if (direct=="RIGHT"){
    if (copyWidth-mainWidth-objMain.scrollLeft>=0){
    objMain.scrollLeft=contentWidth + copyWidth - mainWidth;
    }else{
    objMain.scrollLeft-=2;
    }
    }else if (direct=="UP"){
    if (copyHeight-objMain.scrollTop<=0){
    objMain.scrollTop-=contentHeight;
    }else{
    objMain.scrollTop+=2;
    }
    }else if (direct=="DOWN"){
    if (copyHeight-mainHeight-objMain.scrollTop>=0){
    objMain.scrollTop=contentHeight + copyHeight - mainHeight;
    }else{
    objMain.scrollTop-=2;
    }
    }
    }var v1Scroll = setInterval(new Function("Marquee('LEFT','demo','demo1','demo2')"),speed);
    v1demo.onmouseover=function() {clearInterval(v1Scroll)}
    v1demo.onmouseout=function() {v1Scroll=setInterval(new Function("Marquee('LEFT','demo','demo1','demo2')"),speed)}</script>
    我想把脚本里的代码都封装起来,然后页面下通过调用一个函数,能够表现出和没有封装前一样的效果~~~该怎么写接口函数呢?
      

  3.   

    你说一会有问题一会没问题的CODE长什么样?
    http://community.csdn.net/Expert/topic/5283/5283616.xml?temp=.3778803
    里面有滚动。