简体   繁体   English

如何在同一选项卡中重定向页面

[英]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.我在 IE8 的同一个选项卡中使用了不同的代码行来打开网页,但它们似乎不起作用。 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 查看以下实验室: labs.codeteam.in/lab/~jRrO2NKaH9d6cD9Ph6s1HTE1bis7MVd

In this case I have used window.top.location because the code is executed inside the iframe. 在这种情况下,我使用window.top.location是因为代码是在iframe中执行的。 In your case you only need to use window.location 在您的情况下,您只需要使用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.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