2010-06-05 53 views
2

我在我的页面中使用了两个框架。 Main fame中的页面将获得输入,并且Top框架必须显示结果页面。Response.write和目标框架

我在主机页面中使用以下代码。但它表明

错误: “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>"); 

回答

1

好的,对于初学者(这里没有进攻),但框架吸。你可以尝试使用iFrames吗?

如果您使用iframe,那么你就可以有一个像

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

标签,那么你可以设置的iFrame属性

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

注意:我使用了一个.NET示例,因为我“假设”您使用的是.NET ...很抱歉,如果我错了。 – 2010-06-05 05:20:24

+0

我会尝试相同的方法,但用''。基本上,在代码中runat =“server”'的任何东西都可以让你从后面的代码中操作它。在这种情况下,'Attributes.Add' – 2010-06-05 05:30:55

+0

您可以将'topFrame'变量存储在某种全局变量或会话变量中吗?然后,您可以从放置代码的页面调用该变量。topFrame.Attributes.Add(“src”,Session(“topFrame”)' – 2010-06-05 05:38:57

0

尝试window.topFrame.location.hrefparent.topFrame.location.href

+0

我得到两个选项以下。 “Microsoft JScript运行时错误:'window.topFrame.location'为空或不是对象” – Geeth 2010-06-05 05:24:28