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

纵然是瞬间 提交于 2019-12-12 18:29:29

问题


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

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

All I get is the alert.

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

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

Whats going on?
It's driving me nuts.


回答1:


I found that this works

top.close();

From within the browser address bar

javascript:top.close();



回答2:


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

Worked:

window.close();

Didn't worked:

myWindow.close();



回答3:


A better presentation:

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



来源:https://stackoverflow.com/questions/10612321/javascriptwindow-close-doesnt-close-the-tab-in-ie-8

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!