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

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

醉折花枝作酒筹
Release: 2021-06-15 12:00:36
Original
2444 people have browsed it

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');
Copy after login

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();
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template