簡體   English   中英

如何在同一選項卡中重定向頁面

[英]How can I redirect pages in the same tab

我在 IE8 的同一個選項卡中使用了不同的代碼行來打開網頁,但它們似乎不起作用。 只有這段代碼對我有用......在新標簽頁中打開頁面

window.open("abc.html","_blank");  

有什么問題??

采用

window.location = "xyz.html"

查看以下實驗室: labs.codeteam.in/lab/~jRrO2NKaH9d6cD9Ph6s1HTE1bis7MVd

在這種情況下,我使用window.top.location是因為代碼是在iframe中執行的。 在您的情況下,您只需要使用window.location

請嘗試以下代碼段:

document.location.href = "http://www.google.com";

如果您使用 asp.net 按鈕並希望使用目標屬性在使用 javascript 的同一選項卡中打開:

<asp:Button ID="Button1" runat="server" Width="80px" Text="Exit"
 OnClientClick="opennewtab_1();" OnClick="CodeBehind_Click_1" />

<script type="text/javascript" language="javascript">
    function opennewtab_1() {
        document.forms[0].target = "_self";
    }
</script>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM