1.用Response.Write("<script>document.frames.myframe.location.href='aa.html';</script>")时
出现 document.frames.myframe.location.href不是对象或为空。错误!2.用document.getElementById('myframe').src='aa.html';时,出现 document.getElementById('myframe').不是对象或为空。错误!到底该怎么在后台找到myframe(iframe的id)对象?罗嗦一句,我要实现效果,点击不同按钮,在iframe里显示不同页面,很简单吧!

解决方案 »

  1.   

    有一个折中的办法
    iframe 里面的src用变量 src=<%=aaa%>然后在后台赋值
    protected string aaa
    aaa="aa.html";
      

  2.   

    用<%%>不太好吧,也不方便
    难道就不能用document...的方法吗?
    高人指点啊!
      

  3.   

    <IFRAME id="ifrm" height="100%" width="100%"   frameBorder="no"
     scrolling="no" runat="server" IFRAME>Page_Load
     ifrm.Attributes.Add("src", "xxx.aspx?a=1&b=2")
      

  4.   

    to:justdoit006(我的心太乱) 
      用ifrm.Attributes.Add("src", "xxx.aspx?a=1&b=2")
    还是说找不到ifrm,我要问的是,怎么就在后台得不到iframe对象呢?
      

  5.   

    or<IFRAME id="ifrm" height="100%" width="100%"   frameBorder="no"
     scrolling="no" runat="server" </IFRAME>CType(Page.FindControl("ifrm"), HtmlGenericControl).Attributes.Add("src", "xxx.aspx?a=1&b=2")
      

  6.   

    document.all("iframename").src="hh.html"
      

  7.   

    就是说document.all("iframename")对象为空啊!!!!!!!!!!!!!!!!!!!!!!!!!!!!!to: justdoit006(我的心太乱)
    能不能给个c#的?
    我的问题是,怎么得到iframe的id值,以便改变src的值,怎么老是报错document.frames.myframe.location.href不是对象或为空!!!!!!!!!!!!!!!!!!!!!!!!很急,高手就帮帮忙吧!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
      

  8.   

    Response.Write("<script language=javascript>");
    Response.Write("window.open('http://www.yahoo.com.cn','MainFrame','');");
    Response.Write("</script>");
    'MainFrame'是iframe的id,他怎么是新打开一页显示,而不是嵌在iframe里呢???
      

  9.   

    <script>myframe.window.location.href="aa.html";</script>
      

  10.   

    在aspx的<form></form>之间加入如下代码:
    <IFRAME id="ifrm" height="100%" width="100%" frameBorder="no" scrolling="no" runat="server">
    </IFRAME>在cs的声明部分加入iframe的声明:
    protected System.Web.UI.HtmlControls.HtmlGenericControl ifrm;在Page_Load中加入:
    ifrm.Attributes["src"]="http://www.google.com";保证好用!
      

  11.   

    <script language="javascript">
    function ShowFrame(st)
    {
    switch(st)
    {
    case 1:

    document.frames["CenterFrame"].location="Myfile.aspx";
    break;
    case 2:

    document.frames["CenterFrame"].location="Group.aspx";
    }
    </script>
    在后台调用ShowFrame()
      

  12.   

    晕~想实现你说的那个功能~
    换个思路不行吗?非要更改src属性~
    直接让myframe那个窗口跳转到你想要显示的页面不就可以了~
      

  13.   

    jeffidea(程序诗人)是正解!
    我在一国外论坛找到的答案:
    <iframe id="MyIFrame"></iframe>then in codebehind after declaring 
    protected HtmlGenericControl MyIFrame;doing
    MyIFrame.Attributes["src"] = Request["srcPage"];Aaron.结贴了!同志们加油啊!