PDA

View Full Version : how to close window of browser ?



YYSAM
8 Jul 2009, 10:11 PM
Hello everyone, I want to close the current window by javascript, but I can't found a generic solution to reslove it. following code is I searched in google, it only works in IE.



closeWindow : function() {
//work well.
if (Ext.isIE) {
window.opener = '';
window.close();
}
//doesn't work
else if (Ext.isGecko) {
window.open('', '_parent', '');
window.close();
} else{
// like safari?chrome?Opera?....
}
return false;
}


Firefox web browser doesn't support to close window by script, and I jsut guess that are there some other methods to close window or else?

9 Jul 2009, 3:57 AM
if you have questions about firefox specific javascript methods, try the mozilla developer website.

henryli86
10 Jul 2009, 6:13 AM
I am having the same problem. anyone please help? thank you very much.

10 Jul 2009, 6:18 AM
I am having the same problem. anyone please help? thank you very much.

if you have questions about firefox specific javascript methods, try the mozilla developer website.

Here's a link https://developer.mozilla.org/en/about_javascript

henryli86
14 Jul 2009, 5:42 AM
whenever extjs is used on any page, window.close() stops working in FF. Don't you think this is EXT issue? If I were you, I would not post unless I really understand the problem and can provide a solution. thank you.

14 Jul 2009, 5:51 AM
whenever extjs is used on any page, window.close() stops working in FF. Don't you think this is EXT issue? If I were you, I would not post unless I really understand the problem and can provide a solution. thank you.

If i were you, I would have worked to state the problem clearly, which the original poster did not. Continuing to post sarcasm to volunteers will only lead into you not being helped in the future.

Have you considered turning on firebug warnings?!

It's not always the case where Ext JS is involved! http://tdg-i.com/img/screencasts/2009-07-14_0947.swf take a gander at that video. I'm able to use window.close() where Ext JS is present - but not always.

tryanDLS
14 Jul 2009, 6:19 AM
whenever extjs is used on any page, window.close() stops working in FF. Don't you think this is EXT issue? If I were you, I would not post unless I really understand the problem and can provide a solution. thank you.
Before advising volunteers on how to post, you might consider your statement. You need to understand the difference between JavaScript (Ext or otherwise) running on the page and basic browser functionality. JavaScript cannot break window.close

raduloff
4 May 2011, 2:28 AM
For Google Chrom and FF in your index.html page add:

<script type="text/javascript">

window.open('', '_self', '');
</script>
then you can use window.close() anywhere in your ExtJS application

For FF you must also to open C:\Program Files\Mozilla Firefox\greprefs\all.js and change:
pref("dom.allow_scripts_to_close_windows", false);
to
pref("dom.allow_scripts_to_close_windows", true);