<%@ Page Language="C#" AutoEventWireup="true" CodeFile="w_rollbar.aspx.cs" Inherits="w_rollbar" %><!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 runat="server">
    <title></title>
    <link href="CSS/base.css" rel="Stylesheet" type="text/css" /> 
    <script type="text/javascript">
        function rollbarcontrol() {
            if (window.parent.hiframe.cols == "0,11,*") {
                imgrollbar.src = "img/roll_left.gif";
                window.parent.hiframe.cols = "235,11,*";
            }
            else {
                imgrollbar.src = "img/roll_right.gif";
                window.parent.hiframe.cols = "0,11,*";
            }
        }
    </script>
</head>
<body>
    <form id="form1" runat="server">
        <div>
            <table id="trollbar" cellpadding="0" cellspacing="0">
                <tr>
                    <td onclick="rollbarcontrol();">
                        <img id="imgrollbar" src="img/roll_left.gif" alt="bb" />
                    </td>
                </tr>
            </table>
        </div>
    </form>
</body>
</html>
执行到“imgrollbar.src = "img/roll_right.gif";”时系统报:“Microsoft JScript 运行时错误:‘imgrollbar’未定义”各位大大们帮一下忙,谢谢!

解决方案 »

  1.   

    document.getElementById('imgrollbar').src= "img/roll_right.gif";
      

  2.   

    楼主多看一下dom方面的知识
    imgrollbar是一个img标签
    imgrollbar.src = "img/roll_left.gif";//这样是错误的
    document.getElementById('imgrollbar').src= "img/roll_right.gif";//这样正确
      

  3.   

    首先不知道hiframe是什么是一个name值么?
      

  4.   

    现在报:Microsoft JScript 运行时错误: 'document.getElementById(...)' 为空或不是对象
      

  5.   

    估计就是window.parent.hiframe.cols的问题?hiframe是什么?
      

  6.   

    name?如果是name应该:window.parent.["hiframe"].cols
      

  7.   

    <html>
        <head>
            <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
            <title></title>
        </head>
        <frameset rows="85,*,22" cols="*" frameborder="no" border="0" framespacing="0">
            <frame src="w_top.aspx" scrolling="No" noresize="noresize" />
            <frameset id="hiframe" rows="*" cols="235,11,*" framespacing="0" frameborder="no" border="0" >
                <frame src="" noresize="noresize"  />
            <frame src="w_rollbar.aspx" frameborder="no" scrolling="no" noresize="noresize" />
                <frame src="" />
            </frameset>
            <frame src="w_bottom.aspx" />
        </frameset>
        <noframes>
            <body>
            </body>
        </noframes>
    </html>这是外面的框架页
      

  8.   

    window.parent.document.getElementById("hiframe").cols试一试
      

  9.   

    imgrollbar 貌似没看到你有定义这个对象哦!
      

  10.   

    function rollbarcontrol() {
        if (window.parent.document.getElementById('hiframe').cols == "0,11,*") {
            document.getElementById('imgrollbar').src = "img/roll_left.gif";
            window.parent.document.getElementById('hiframe').cols = "235,11,*";
        }
        else {
            document.getElementById('imgrollbar').src = "img/roll_right.gif";
            window.parent.document.getElementById('hiframe').cols = "0,11,*";
        }
    }