internet explorer - javascript:window.close(); doesn't close the tab in IE 8 - Stack Overflow

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

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.

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.

Share Improve this question asked May 16, 2012 at 5:04 MintMint 16k32 gold badges83 silver badges109 bronze badges 5
  • It should not work, it is a bug. You should not be able to close a window you did not create since you destroy a user's history. – epascarello Commented May 16, 2012 at 5:08
  • It's a client requirement so I can't really work around it, as much as I may hate the idea. and they have it done on other projects so they wont understand why it cant work now. I'v done it before and it works. It just doesn't seem to now. – Mint Commented May 16, 2012 at 5:14
  • Why you open new document in current window ('_self')? – Andrew D. Commented May 16, 2012 at 5:46
  • It's meant to be a work around to the "do you really want to close this window" popup. Another client requirement. These are all internal sites. – Mint Commented May 16, 2012 at 6:00
  • top.close(); seems to work... – Mint Commented May 16, 2012 at 6:01
Add a ment  | 

3 Answers 3

Reset to default 3

I found that this works

top.close();

From within the browser address bar

javascript:top.close();

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

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

Worked:

window.close();

Didn't worked:

myWindow.close();

A better presentation:

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

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1742316004a4420849.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信