Thursday, May 23, 2024
 Popular · Latest · Hot · Upcoming
65
rated 0 times [  71] [ 6]  / answers: 1 / hits: 35406  / 13 Years ago, mon, march 28, 2011, 12:00:00

I need to close the browser window using the java script.



I have tried using window.close but it is not working.



I have also googled and checked stack overflow for any similar posts. I have also gone through following link but in vain.



Is it possible to close browser window from JavaScript?



What I am trying to do is load a page and on load of the page call a java script method which does window.close



Below is the code



<!DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.0 Transitional//EN>
<html>
<head>
<script>
function closeBrowser(){
window.close();
}
</script>
</head>
<body onload=closeBrowser();>
</body>
</html>


It is properly working in IE8 though. Its not working in the fire fox.



And even in IE it gives the alert prompt before actually closing the browser. Can we avoid the alert in IE?



Why it does not work in fire fox?


More From » javascript

 Answers
55

The reason it was not working in fire fox was due to some settings in the fire fox.



Please set your firefox browser:



1.input about:config to your firefox address bar and enter;



2.make sure your dom.allow_scripts_to_close_windows is true



window.close is now working in fire fox too.


[#93050] Friday, March 25, 2011, 13 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
tina

Total Points: 91
Total Questions: 106
Total Answers: 104

Location: Vanuatu
Member since Fri, May 13, 2022
2 Years ago
;