使用javascript setTimeout函数在新选项卡中打开新url
一段时间后,我正在尝试在新选项卡中打开URL使用javascript setTimeout函数在新选项卡中打开新url,javascript,redirect,window,url-redirection,Javascript,Redirect,Window,Url Redirection,一段时间后,我正在尝试在新选项卡中打开URL <script type="text/JavaScript"> setTimeout("location.href = 'http://google.com/';",3000); </script> setTimeout(“location.href=”http://google.com/';",3000); 上述代码将在同一选项卡中打开url。 但我想在新选项卡或新窗口中打开url。您可以使用 plnkr“
<script type="text/JavaScript">
setTimeout("location.href = 'http://google.com/';",3000);
</script>
setTimeout(“location.href=”http://google.com/';",3000);
上述代码将在同一选项卡中打开url。但我想在新选项卡或新窗口中打开url。您可以使用 plnkr“打开”功能有帮助吗
setTimeout(
function(){
window.open("http://www.google.com")
},1000)
您所拥有的已经很接近了,您只需要将您的逻辑存储在回调中,然后删除。href 例如
setTimeout(function(){
window.location = 'http://google.com/';
},3000)
//FYI this will redirect page in the same tab vs .open() opens a new tab...
希望这有帮助这将在同一选项卡中打开
setTimeout(function(){
window.location = 'http://google.com/';
},3000)
//FYI this will redirect page in the same tab vs .open() opens a new tab...