2010-06-05 50 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