Home>Article>Web Front-end> How to avoid pop-up window in window.close in javascript
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.
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!