繁体   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