简体   繁体   中英

How can I redirect pages in the same tab

I have used different code lines for opening webpages in the same tab in IE8 But they do not seem to work. Only this piece of code works for me... that to opens page in new tab

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

What's the problem??

Use

window.location = "xyz.html"

Look at the below Lab: labs.codeteam.in/lab/~jRrO2NKaH9d6cD9Ph6s1HTE1bis7MVd

In this case I have used window.top.location because the code is executed inside the iframe. In your case you only need to use window.location

请尝试以下代码段:

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

If you're using asp.net buttons and would like to use target properties to open in the same tab using 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>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM