Home>Article>Web Front-end> How to avoid pop-up window in window.close in javascript

How to avoid pop-up window in window.close in javascript

醉折花枝作酒筹
醉折花枝作酒筹 Original
2021-06-15 12:00:36 2340browse

In javascript, you can add the statement "window.opener=null;window.open('','_self');" before window.close to prevent pop-ups. window.opener refers to the page opened by window.open.

How to avoid pop-up window in window.close in javascript

The operating environment of this tutorial: windows7 system, javascript version 1.8.5, Dell G3 computer.

Add

window.opener = null; window.open('', '_self');

before window.close();? and you will not be prompted ‘Do you want to close this window’!

So the method to open a new webpage and close the current page is:

window.open(newurl); window.opener = null; window.open('', '_self'); window.close();

where newurl is the URL of the page to be redirected.

[Recommended learning:javascript advanced tutorial]

The above is the detailed content of How to avoid pop-up window in window.close in javascript. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn