gpt4 book ai didi

javascript - 如何仅在一个窗口/选项卡中打开 HTML

转载 作者:行者123 更新时间:2023-11-28 01:24:31 24 4
gpt4 key购买 nike

我想做的事 -

1) On Click of a button I will open a new window(popup).

2) When I click on same button, If the window(popup)is already open I will not open it again instead bring the previously opened window(popup) on top of all windows.

3) If popup is not open I will use window.open() to open a popup.

到目前为止我做了什么 -

1) On Click of a button I will open a new window(popup).

2) Problem : How do I not allow opening of new window on click of button if window is already open?

最佳答案

给你:

Javascript函数:

<script language="javascript" type="text/javascript">
function popitup(url) {
newwindow=window.open(url,'name','height=200,width=150');
if (window.focus) {newwindow.focus()}
return false;
}
</script>

HTML 标签:

<a href="popupex.html" onclick="return popitup('popupex.html')">Link to popup</a>

来源:http://www.quirksmode.org/js/popup.html
请查看其来源以及他们如何使其发挥作用。他们也确实提供了一些您所需要的示例。

关于javascript - 如何仅在一个窗口/选项卡中打开 HTML,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22857820/

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