javascript:window.close(); 不会关闭 IE 8 中的选项卡

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/10612321/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-24 02:09:18  来源:igfitidea点击:

javascript:window.close(); doesn't close the tab in IE 8

javascriptinternet-exploreradobe-captivate

提问by Mint

It works in Chrome and I thought it used to work in IE8... but it doesn't seem to.

它在 Chrome 中工作,我认为它曾经在 IE8 中工作......但似乎没有。

javascript:window.open('', '_self', ''); window.close();alert('test');

All I get is the alert.

我得到的只是alert.

Basically i'm trying to execute a function which works fine in the browser as an alink, but using the same code in captivates "execute javascript" on a button, doesn't work.

基本上,我试图执行一个在浏览器中作为a链接正常工作的函数,但是在一个按钮上使用相同的代码“执行 javascript”,不起作用。

Then I thought I would test it using javascript:in IE... and it doesn't close it ether.

然后我想我会javascript:在 IE 中使用它来测试它......它并没有关闭它。

Whats going on?
It's driving me nuts.

这是怎么回事?
它让我发疯。

回答by Mint

I found that this works

我发现这有效

top.close();

From within the browser address bar

从浏览器地址栏中

javascript:top.close();

回答by Ziggler

I don't know why, but the example from the link below didn't work for me.

我不知道为什么,但是下面链接中的示例对我不起作用。

http://www.w3schools.com/jsref/met_win_close.asp

http://www.w3schools.com/jsref/met_win_close.asp

Worked:

工作过:

window.close();

Didn't worked:

没有用:

myWindow.close();

回答by S.H.Kashani

A better presentation:

更好的介绍:

onclick="javascript: window.open('', '_self', ''); window.close();"

onclick="javascript: window.open('', '_self', ''); window.close();"