gpt4 book ai didi

javascript - 如何在新窗口打开

转载 作者:行者123 更新时间:2023-12-01 01:25:42 32 4
gpt4 key购买 nike

我还有一个问题:(这是我的脚本

<script type="text/JavaScript">
function first()
{
var first = confirm("Are you sure you want to navigate away from this page?");
if (first)
window.location = "http://www.yahoo.com.sg"
else
window.close;
}
function second()
{
var second = confirm("Are you sure you want to navigate away from this page?");
if (second)
window.location = "http://www.google.com"
else
window.close;
}
</script>


<p><b>Click the following link to enter yahoo</b></p>
<p><a href="javascript:first()"title="Opens in an external website in a new window">yahoo</a></p>

<p><b>Click the following link to check google</b></p>
<p><a href="javascript:second()" title="Opens in an external website in a new window">google</a></p>

它不会在新窗口中打开。我需要一些帮助。有什么建议或建议吗?

最佳答案

尝试 window.open .这将打开一个新窗口:

window.open("http://www.google.com");

另见:

关于javascript - 如何在新窗口打开,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10242908/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com