gpt4 book ai didi

javascript - 如何在新窗口中打开网页(弹出)

转载 作者:太空宇宙 更新时间:2023-11-04 12:16:49 28 4
gpt4 key购买 nike

我正在设计一个网页,我希望当用户单击链接时,弹出窗口(新窗口)将打开一个链接网页。我的代码如下所示

<head>
<script language="javascript">
function win(add,w,h)
{
window.open(add,"","width="+w+",height="+h+",location=0,directories=0,menubar=0,toolbar=0,status=0,scrollbars=1,resizable=1,top=5,left=5");
window.location.reload();
}
</script>
</head>

<body>
<h1>Click to open link in new window</h1>
<ul>
<li><a href="#" class="Menu">Account Master</a>
<ul>
<li><a href="#" value="new.htm" onclick="win(this.value,600,450)">New</a></li>
<li><a href="#" value="mod.html" onclick="win(this.value,600,500)" >Modify</a></li>
<li><a href="#" value="del.html" onclick="win(this.value,600,500)">Delete</a></li>
<li><a href="#" value="view.html" onclick="win(this.value,600,500)">View</a></li>
</ul>
</li>
</ul>
</body>

在 Firefox 中,单击链接会出现一个弹出窗口,但没有打开链接(意味着它只打开空白页面),而在 IE 弹出窗口中,会出现带有链接(/未定义)的链接,而不是链接提供的链接。我无法检测到错误是什么。

最佳答案

试试这个...

<head>
<script language="javascript">
function win(add,w,h)
{

window.open(add,"","width="+w+",height="+h+",location=0,directories=0,menubar=0,toolbar=0,status=0,scrollbars=1,resizable=1,top=5,left=5");
window.location.reload();
}

</script>
</head>

<body>
<h1>Click to open link in new window</h1>
<ul>
<li><a href="#" class="Menu">Account Master</a>
<ul>
<li><a href="new.htm" value="new.htm" target="_blank" onclick="win(this.href,600,450)">New</a></li>
<li><a href="mod.html" value="mod.html" target="_blank" onclick="win(this.href,600,500)" >Modify</a></li>
<li><a href="del.html" value="del.html" target="_blank" onclick="win(this.href,600,500)">Delete</a></li>
<li><a href="view.html" value="view.html" target="_blank" onclick="win(this.href,600,500)">View</a></li>
</ul>
</li>
</ul>
</body>

关于javascript - 如何在新窗口中打开网页(弹出),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28645064/

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