Close this window with javascript without popping up a query

  • 2020-03-30 03:55:13
  • OfStack

In order to achieve the absolute control of the user over the browser, ie USES close to close the window that is not open to pop up a dialog box to ask the user, how to remove this box, see the following code.


function winClose(){ window.top.opener = null; window.close(); }

Just add window.top-opener = null before window.close.

Open firefox and enter about:config in the address bar
Locate the dom.allow_scripts_to_close_windows entry and change to true.
Suffice it to say that there are no pop-ups in firefox.


<script>
function a(){
window.open('','_parent','');
window.opener = window;
window.close(); 
}
</script>

If you run this again you can close it under ff.

See these, if let the customer to set, is not to do this function, so the result is not very satisfactory, I do not know if there are other good alternatives.

Postscript: close the current page by opening a new window and then closing the page. Thank strangebank. But the strange thing is that I didn't succeed with ff2 yesterday, and I succeeded with 3 today. What the heck, today on the colleague machine with 2 to do the experiment, again ok. But it's good to get things done first thing in the morning. ^_^

index.html


<a href="c.html" target="_blank">ddddddddd</a>

C. the TML


<a href="javascript:window.open('','_parent','');window.close();">Close Window</a>

Related articles: