http://zhangqgc.iteye.com/blog/638088这个网页中的方法在IE中表现的很好,但在谷歌浏览器Google Chrome中一直提示:Uncaught TypeError: Cannot call method 'getElementById' of undefined 而无法工作,怎么改进啊?

解决方案 »

  1.   

    多多试试几个浏览器再来判断是浏览器的问题还是code的问题
      

  2.   

    框架代码:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html>
      <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>左右布局侧边栏演示</title>  </head>  <frameset cols="230,*" name="cen" frameborder="no" border="0" framespacing="0">    <frame src="left.html" name="leftFrame"  noresize="noresize" id="leftFrame" title="leftFrame" />    <frame src="right.html" name="mainFrame" id="mainFrame" title="mainFrame" />  </frameset>  <noframes>
        <body>
    <p>此网页使用了框架,但您的浏览器不支持框架。</p>
        </body>
      </noframes>
    </html>
    right.html<html><head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312"><title>main - 51windows.net</title>
    </head><body>
    <SCRIPT LANGUAGE="javascript">
    <!--function shleft(){
     if (parent.cen.cols=="0,*"){
      parent.cen.cols="25%,*,"
      document.getElementById("shleft").value="隐藏左部";
     }
     else{
      parent.cen.cols="0,*"
      document.getElementById("shleft").value="显示左部";
     }
    }//-->
    </SCRIPT><input type="button" name="shleft" id="shleft" onclick="shleft();" value="隐藏左部">
    </body></html>left.html随便弄点内容用谷歌浏览器载入后提示:Uncaught TypeError: Cannot read property 'cols' of undefined 
      

  3.   


    我3楼的源码各位有没有试试,我新装的Google Chrome无法使用啊
      

  4.   

     <frameset cols="230,*" name="cen" frameborder="no" border="0" framespacing="0">
    加ID 改成
     <frameset cols="230,*" name="cen" id="cen" frameborder="no" border="0" framespacing="0">
    <html>
     
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <title>main - 51windows.net</title>
    </head>
     
    <body>
    <SCRIPT LANGUAGE="javascript">
    <!--
    function shleft(){
     var cen=parent.document.getElementById("cen") ;
     if (cen.cols=="0,*"){
       cen.cols="25%,*,"
      document.getElementById("shleft").value="隐藏左部";
     }
     else{
       cen.cols="0,*"
      document.getElementById("shleft").value="显示左部";
     }
    }
     
    //-->
    </SCRIPT>
     
    <input type="button" name="shleft" id="shleft" onclick="shleft();" value="隐藏左部">
     
     
    </body>
     
    </html>这样试试
      

  5.   


    不好用,提示:Uncaught TypeError: Cannot call method 'getElementById' of undefined 
      

  6.   

    还有一种情况  谷歌里要有关iframe操作有些诡异  如果你把项目发布到服务器上可以了  那就是我遇到的那种情况