Home > front end >  Js, how to implement the browser close button
Js, how to implement the browser close button

Time:11-29

My company's project is only use IE browser, can be closed with the following code,
Window. The opener=null;
Window. The open (', 'love');
Window. The close ();
Home only chrome, Edge browser, using the above method is bad to use,
Error message is "Scripts may close only the Windows that were the opened by them"

If the code change:
Window. The opener=null;
Window. The open (" about: blank ', 'love');
Window. The close ();
Two browser will close the current page, but left a about: where is the blank page,

Excuse me how can I in chrome, Edge of perfect close a page?

CodePudding user response:

 & lt; ! DOCTYPE html> 


<meta charset="utf-8" & gt;
<script>
The function closewind () {
Window. The opener=null;
Window. The open (', 'love');
Window. The close ();
}
</script>


<body>


I use the code you write this way don't know whether I meet your actual call
Chrome and 360 is good, not Firefox
The Chrome version 84.0.4147.135 (formal version) (64)

CodePudding user response:

Window. The close (); Or this. Remove (); Or this. Hide ();