gpt4 book ai didi

javascript - html窗口通过javascript打开关闭

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

我想关闭在我的着陆 html 页面中编写的这个 javascript 打开的窗口。

window.open(location,"_self");

在位置 html 页面中,我有一个我尝试使用的按钮

<div onclick="javascript:self.close();">Xyyyy</div>
<div onclick="javascript:window.close();">Xxxx</div>

它们都不起作用。

注意:我的条件是我必须在同一个地方打开新窗口。

需要任何帮助

最佳答案

我搜索了这个主题并且 this page是我发现的。

html (不是我的)

<input type="button" name="Quit" id="Quit" value="Quit" onclick="return quitBox('quit');" />

JavaScript (不是我的)

function quitBox(cmd)
{
if (cmd=='quit')
{
open(location, '_self').close();
}
return false;
}

There is even a test page.

我也搜索过一只小兔子(也不是我的)。

enter image description here

更新:2015 年 3 月 12 日

我搜索了这个主题并且 this page是我发现的。

我用这段代码做了测试,确认它不受支持。评论很好看。

JavaScript (不是我的)

function close_window() {
if (confirm("Close Window?")) {
window.close();
}
}

html (不是我的)

<a href="javascript:close_window();">close</a>

<a href="#" onclick="close_window();return false;">close</a>

关于javascript - html窗口通过javascript打开关闭,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29001565/

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