0
將iframe打開到單獨的url的正確javascript語法是什麼?即我在一個帶有表單的iframe中有一個頁面,提交表單後,我想重定向到站點上的單獨頁面(同一個域),但是在父窗口而不是在iframe內部打開它。這是我已經試過:按鈕點擊跳出iframe到同一個域中的新網址點擊
protected void ReplacePageClick(object sender, EventArgs e)
{
string url = "Contact.aspx";
ClientScriptManager cs = Page.ClientScript;
cs.RegisterClientScriptBlock(this.GetType(), "RedirectScript", "top.document.location.href = " + url, true);
//top.document.parent.location.href?
//top.document.location.replace?
//window.parent.location?
//window.top.location.href?
//window.top.location.replace?
//parent.window.location.href?
//top.location.href?
// the below works, so we know it's able to register javascript
//cs.RegisterClientScriptBlock(this.GetType(), "Alert", "alert('hello')", true);
}
window.open(「url」,「_ top」)工作正常,謝謝!這些頁面位於同一個域中,因此沒有訪問被拒絕的錯誤。 –
然後top.location應該也工作 – mplungjan
不幸的是它沒有。如果你想看一看,我可以把整個源碼放在某個地方? –