开发者

Javascript - closing tab

Is it possible to close a tab via JavaScript?

For example, I have redirected user from email to my page, then I ne开发者_C百科ed to open pop-up window and close the tab I have redirected user to.

Does window.close() work only for windows created with JavaScript? Or is it possible to modify tab, so that becomes a popup window?


window.close() is working only for windows created inside javascript?

window.close should also work for new windows your page has created using target="_blank". Other than that, there is no way to close the current window or tab programmatically. As far as I know, what you want to do - closing an original window that you have not opened - is impossible.


No. You can only control child windows created inside a parent window.

"Is it possible to modify tab, so that it's become popup window?" Only if you have access to the page where it is created.


This might be old, but let's answer it.

I use top.close() to close a tab.

window.close() or other open...close didn't work for me.

top.close() works in chrome too.


if the user has configured his browser to open popups as tabs, you will have that behavior.

in other ways i don't think it is possible...


I don't know if I understand:

You send a link via email. The link needs to open a pop-up with your webpage??? If it is that, simply make the emailed link open in a new window... It will save lots of trouble with javascript...


It can be done. Just use:

window.open('', '_parent', '');
window.close();

It is not My solution but I saw it here: http://www.yournewdesigner.com/css-experiments/javascript-window-close-firefox.html

You can also read why it works in the link.


I had the same problem, the solution for one following:

let win = window.open(null, "_self");
win.close();
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜