原因有3个
1,<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">造成的,删除即可
或者参考2,如果你存成了js文件。将文件存成utf-8
3,或者你引用的id有问题

解决方案 »

  1.   

    或者参考
    http://blog.csdn.net/net_lover/archive/2006/08/25/1116488.aspx
      

  2.   

    我试了还不行,我也没有存成js文件,这样吧,我把原码放上去让你看看,帮我看看好吗?
    万分感谢
    <SCRIPT language=JavaScript src="picture/float.js"></SCRIPT>
    <!--浮动广告代码开始-->
    <DIV id=Layer1 
    style="Z-INDEX: 1; VISIBILITY: visible; WIDTH: 1px; POSITION: absolute; TOP: 100px; HEIGHT: 1px">
    <DIV id=divMenu style="LEFT: 767px; POSITION: absolute; TOP: 0px">
    <TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
      <TBODY>
      <TR>
        <TD>
          <TABLE cellSpacing=0 cellPadding=0 width=106 border=0>
            <TBODY>
            <TR>
              <TD><IMG height=67 src="picture/pic26.gif" width=106></TD></TR>
            <TR>
              <TD>
                <TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
                  <TBODY>
                  <TR>
                    <TD vAlign=top width=11><IMG height=86 
                      src="picture/pic27.gif" width=11></TD>
                    <TD vAlign=top width=86 background=picture/pic30.gif>
                      <SCRIPT language=javascript> 
    var online= new Array(); 
    if (!document.layers) 
    document.write("<div id='divStayTopLeft' style='position:absolute'>") 
    </SCRIPT>                  <TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
                        <SCRIPT src="picture/getonline.htm"></SCRIPT>                    <TBODY>
                        <TR>
                          <TD vAlign=bottom background="" height=30>
                            <SCRIPT> 
    if (online[0]==0) 
    document.write("<img src=new_picture/QQoffline.gif border=0 align=middle>&nbsp;<a class='qqb' target=blank href='http://wpa.qq.com/msgrd?V=1&Uin=52950682&Site=在线咨询&Menu=no' title='客服不在线,请留言'>52950682</a>"); 
    else 
    document.write("<img src=new_picture/QQonline.gif border=0 align=middle>&nbsp;<a class='qqa' target=blank href='http://wpa.qq.com/msgrd?V=1&Uin=52950682&Site=在线咨询&Menu=no' title='在线即时交谈'>52950682</a>"); 
    </SCRIPT>
                          </TD></TR>
                        <TR>
                          <TD vAlign=center background="">热线:13128207221 
                        </TD></TR></TBODY></TABLE></TD>
                    <TD vAlign=top height=9><IMG height=86 
                      src="picture/pic28.gif" 
            width=9></TD></TR></TBODY></TABLE></TD></TR>
            <TR>
              <TD><IMG height=12 src="picture/pic29.gif" 
            width=106></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE></DIV></DIV>
    <SCRIPT language=javascript> if (isNS4)  

    var divMenu = document['divMenu']; 
    divMenu.top = top.pageYOffset + 250; 
    divMenu.visibility = 'visible'; 
    moveRightEdge(); 
    } else if (isDOM) { 
    var divMenu = getRef('divMenu'); 
    divMenu.style.top = (isNS ? window.pageYOffset : document.body.scrollTop) + 250; 
    divMenu.style.visibility = 'visible'; 
    moveRightEdge(); 

    // 广告框调整 
    document.all.divMenu.style.pixelLeft = (document.body.clientWidth - 774 ) /2 + 774 + 5; 
    </SCRIPT>
    <!--浮动广告代码结束-->
    其中的float.js文件原文为:
    function MM_swapImgRestore() { //v3.0
      var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
    }function MM_preloadImages() { //v3.0
      var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
        var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
        if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
    }function MM_findObj(n, d) { //v3.0
      var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
        d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
      if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
      for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document); return x;
    }function MM_swapImage() { //v3.0
      var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
       if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
    }function MM_showHideLayers() { //v3.0
      var i,p,v,obj,args=MM_showHideLayers.arguments;
      for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
        if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v='hide')?'hidden':v; }
        obj.visibility=v; }
    }function makePop(url, winname, width, height, scrolltype)
    {
       xposition=0; yposition=0;
       if (parseInt(navigator.appVersion) >= 4){
          xposition = (screen.width - width) / 2;
          yposition = (screen.height - height) / 2;
       }
       args = "width=" + width + "," + "height=" + height + "," + "location=0," + "menubar=0," + "resizable=0,"
             + "scrollbars=" + scrolltype + "," + "status=0," + "titlebar=0," + "toolbar=0," + "hotkeys=0,"
       + "screenx=" + xposition + ","  //NN Only
       + "screeny=" + yposition + ","  //NN Only
       + "left=" + xposition + ","     //IE Only
       + "top=" + yposition;           //IE Only   newWin=window.open(url,winname,args)
       newWin.focus();
    }function makeWin(url, winname, width, height, scrolltype)
    {
       xposition=0; yposition=0;
       if (parseInt(navigator.appVersion) >= 4){
          xposition = (screen.width - width) / 2;
          yposition = (screen.height - height) / 2;
       }
       args = "width=" + width + "," + "height=" + height + "," + "location=0," + "menubar=0," + "resizable=0,"
             + "scrollbars=" + scrolltype + "," + "status=0," + "titlebar=0," + "toolbar=0," + "hotkeys=0,"
       + "screenx=" + xposition + ","  //NN Only
       + "screeny=" + yposition + ","  //NN Only
       + "left=" + xposition + ","     //IE Only
       + "top=" + yposition;           //IE Only   newWin=window.open(url,winname,args)
       newWin.focus();
    }function space_check(strObj) { //傍归眉农 var strValue = strObj.value;
    var intCode = 0; for (i = 0; i < strValue.length; i++) {
    var intCode = strValue.charCodeAt(i)
    var retChar = strValue.substr(i,1).toUpperCase()
    intCode = parseInt(intCode)
    if (retChar == " " ) return false;
    }
    return true;
    }function search(form) {
    if(!space_check(form.key)){
    alert("八祸绢俊 傍鄂阑 涝仿窍矫搁 救邓聪促.");   
    form.key.focus();
    return false;
    }
    if(form.key.value.length == 0) {
    alert("八祸绢甫 涝仿秦林技夸");
    form.key.focus();
    return false;
    }
    }function SelMenu(index,flag)
    {
    if(flag == 'on')
    {
    flag = "visible";
    target = eval("document.all['layer" + index + "'].style");
    }
    else
    {
    flag = "hidden";
    target = eval("document.all['layer" + index + "'].style");
    }
    target.visibility = flag;
    }var isDOM = (document.getElementById ? true : false); 
    var isIE4 = ((document.all && !isDOM) ? true : false);
    var isNS4 = (document.layers ? true : false);
    function getRef(id) {
    if (isDOM) return document.getElementById(id);
    if (isIE4) return document.all[id];
    if (isNS4) return document.layers[id];
    }
    var isNS = navigator.appName == "Netscape";
    function moveRightEdge() {
    var yMenuFrom, yMenuTo, yOffset, timeoutNextCheck;
    if (isNS4) {
    yMenuFrom   = divMenu.top;
    yMenuTo     = windows.pageYOffset + 160;   // 困率 困摹
    } else if (isDOM) {
    yMenuFrom   = parseInt (divMenu.style.top, 10);
    yMenuTo     = (isNS ? window.pageYOffset : document.body.scrollTop) + 160; // 困率 困摹
    }
    timeoutNextCheck = 500;
    if (yMenuFrom != yMenuTo) {
    yOffset = Math.ceil(Math.abs(yMenuTo - yMenuFrom) / 20);
    if (yMenuTo < yMenuFrom)
    yOffset = -yOffset;
    if (isNS4)
    divMenu.top += yOffset;
    else if (isDOM)
    divMenu.style.top = parseInt (divMenu.style.top, 10) + yOffset;
    timeoutNextCheck = 10;
    }
    setTimeout ("moveRightEdge()", timeoutNextCheck);
    }
      

  3.   

    孟老大见笑了,因为我刚转开发BS,所以javascript很烂,请多多赐教
      

  4.   

    下面是对联式的代码。
    保存成js,然后在页面调用即可。
    注意修改图片位置,如果只要其中一个则删除一个即可。
        var delta=0.15
    var collection;
    function floaters() {
    this.items = [];
    this.addItem = function(id,x,y,content)
      {
    document.write('<DIV id='+id+' style="Z-INDEX: 10; POSITION: absolute;  width:80px; height:60px;left:'+(typeof(x)=='string'?eval(x):x)+';top:'+(typeof(y)=='string'?eval(y):y)+'">'+content+'</DIV>');

    var newItem = {};
    newItem.object = document.getElementById(id);
    newItem.x = x;
    newItem.y = y; this.items[this.items.length] = newItem;
      }
    this.play = function()
      {
    collection = this.items
    setInterval('play()',10);
      }
    }
    function play()
    {
    if(screen.width<=800)
    {
    for(var i=0;i<collection.length;i++)
    {
    collection[i].object.style.display = 'none';
    }
    return;
    }
    for(var i=0;i<collection.length;i++)
    {
    var followObj = collection[i].object;
    var followObj_x = (typeof(collection[i].x)=='string'?eval(collection[i].x):collection[i].x);
    var followObj_y = (typeof(collection[i].y)=='string'?eval(collection[i].y):collection[i].y); if(followObj.offsetLeft!=(document.body.scrollLeft+followObj_x)) {
    var dx=(document.body.scrollLeft+followObj_x-followObj.offsetLeft)*delta;
    dx=(dx>0?1:-1)*Math.ceil(Math.abs(dx));
    followObj.style.left=followObj.offsetLeft+dx;
    } if(followObj.offsetTop!=(document.body.scrollTop+followObj_y)) {
    var dy=(document.body.scrollTop+followObj_y-followObj.offsetTop)*delta;
    dy=(dy>0?1:-1)*Math.ceil(Math.abs(dy));
    followObj.style.top=followObj.offsetTop+dy;
    }
    followObj.style.display = '';
    }
    }

    var theFloaters = new floaters();
    theFloaters.addItem('followDiv1','document.body.clientWidth-100',80,'<a href="/"><img src=images/qz.gif width=89height=426 border="0"></a>');
    theFloaters.addItem('followDiv2',10,80,'<a href="/"><img src=images/qz.gif width=89 height=426 border="0"></a>');
    theFloaters.play();
      

  5.   

    兄弟,和我上面的代码一样,一开始一切正常,没任何错误,但是滚动条往下拉的时候它就是不动啊!!!你是不是也放在aspx页面中阿(其实理论上跟这个没关系的) 我快疯了,帮帮忙了啊