Windows Self-band method
Window.close ()
The code is as follows |
Copy Code |
<a href= "Javascript:self.close ()" > Close window </a> |
This approach is a lot of problems, incompatible is not more introduced, the following we look at an example
Window.close () is OK, but it will give you a hint. The page you are viewing is attempting to close the window. Do you want to close the window? "How can you not eject this hint?"
"If you open this page for the first time, Window.close () will pop-up prompts, if this page is by other pages window.open () out of the page, Window.close (), there will be no prompts
window does not prompt for automatic shutdown of JS code
The code is as follows |
Copy Code |
Normal with tips off function Closeie () { Window.close (); } Close IE6 do not prompt function Closeie6 () { Window.opener=null; Window.close (); } Close IE7 do not prompt function Closeie7 () { window.open (', ' _top '); Window.top.close (); }
But all in |
FF is not used up, and later found a good compatible with all browsers to close the current page function
code is as follows |
copy code |
function Closewebpage () { if (navigator.userAgent.indexOf ("MSIE") > 0) { if (navigator.userAgent.indexOf ("MSIE 6.0") > 0) { window.opener = nul L window.close (); } else { window.open (', ' _top '); window.top.close (); &NBSP;&NBSP} } else if (navigator.userAgent.indexOf ("Firefox") > 0) { window.location.href = ' About:blank '; } else { window.opener = null; window.open (', ' _self ', '); Window.close (); } } |