【问题标题】:Response.write and target frameResponse.write 和目标框架
【发布时间】:2010-06-05 05:14:10
【问题描述】:

我在我的页面中使用了两个框架。 Main名中的页面将获得输入,而Top frame必须显示结果页面。

我在大型机页面中使用以下代码。但它显示了

错误:“Microsoft JScript 运行时错误:'topFrame' 未定义”

代码:

  <frame src="" id="topFrame" target="topFrame"  scrolling="no">
  <frame src="txtPage.aspx" target="topFrame" name="mainFrame">

  txtPage(MainFrame)
  Response.Write("<script>topFrame.location.href=\"Homepage.aspx\";</script>");

【问题讨论】:

    标签: c# asp.net javascript frames


    【解决方案1】:

    好的,对于初学者(这里没有冒犯),但是框架很烂。您可以尝试使用 iFrame 吗?

    如果你使用 iFrame,那么你可以有一个类似的标签

    <iframe src="" id="topFrame" target="topFrame"  scrolling="no" runat="server"></iframe>
    

    那么就可以设置iFrame属性了

    topFrame.Attributes.Add("src", "/homepage.aspx")
    

    【讨论】:

    • 注意:我使用 .NET 示例是因为我“假设”您使用的是 .NET……如果我错了,请见谅。
    • 我会尝试相同的方法,但使用&lt;frame&gt;。基本上,您在代码中runat="server" 的任何内容都将允许您从后面的代码中对其进行操作。在这种情况下Attributes.Add
    • 你可以将topFrame 变量存储在某种全局变量或会话变量中吗?然后您可以从您放入代码的页面调用该变量。topFrame.Attributes.Add("src", Session("topFrame")
    • 在哪里Session("topFrame") = "/homepage.aspx"
    • 嗨,还有一个疑问。我关注你的问题是,topFrame.Attributes.Add("src", Session["topframe"].ToString());在页面加载中,但此事件未触发。
    【解决方案2】:

    试试window.topFrame.location.href 或parent.topFrame.location.href。

    【讨论】:

    • 我得到以下两个选项。 "Microsoft JScript 运行时错误:'window.topFrame.location' 为空或不是对象"
    猜你喜欢
    • 1970-01-01
    • 2011-02-24
    • 1970-01-01
    • 1970-01-01
    • 2017-01-05
    • 1970-01-01
    相关资源
    最近更新 更多