简体   繁体   中英

Simply opening only one tab at window.open

For example, my html file:

<script>
    window.open('http://stackoverflow.com/');
</script>

I run my file . I want that only Stack Overflow tab opened. I don't want that tab before the Stack Overflow tab opened. What do I have to make? Without use the server.

使用window.location.href加载当前选项卡。

window.location.href='http://stackoverflow.com';

This obviously happens because the window which runs your script isn't closed after the script is run. Then you should close the window.

<script>
    window.open('http://stackoverflow.com/');
    window.close();
</script>

您可以在加载函数中使用window.location.href="http://stackoverflow.com/"

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