Hi
I need a method to close the main browser window usingwithout getting a confirmation prompt.Code:window.close()
Is this possible or is there any other way to achieve the same result?
Any help will be highly appreciated.
Regards
Hi
I need a method to close the main browser window usingwithout getting a confirmation prompt.Code:window.close()
Is this possible or is there any other way to achieve the same result?
Any help will be highly appreciated.
Regards
Please have a look to the attachment(open.html).Its just a work around as I think its not possible to close the browAttachment 760eser window without an alert msg.
The files you attached in your posting doesn't working as I want. Let me clear my points.
1. I have only one window which is not generated using script. (There is no scope for a popup window in my case).
2. I need to close my only window (main window) using JavaScript code in such a way that it doesn't show the browser closing confirmation box.
Fine ...I got your point.
Please try this attachment. I tested it in i.e.6.0. Its working fine Attachment 761.
code:
<script language="JavaScript">
function fCloseOpener(){
window.opener = self
window.close()
}
</script>
Last edited by beeps; 01-31-2007 at 09:00 AM. Reason: attachment
John came up with a code that does this. It convinces JS that the window WAS opened by it then allows it to close the window. Search around for it... not sure where it is at the moment.
Edit: here we go...
He said, in short, that once this is on the page, it allows window.close() etc. to work properly.Code:<script type="text/javascript"> if(window.name!='prime'){ window.name='prime'; window.open(window.location.href, 'prime') } </script>
Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum
I found that, for some reason, IE versions 6 and below didn't like that but, they always had responded well to another hack that other browsers ignored so, in the end I went with this:
What it does is to reopen the window in the same window using javascript based upon whether or not it has the name 'prime'. Then (except in IE 6 and below) it can be closed using javascript. In IE 6 and less it also tells the browser, "Hey - I am the opener so, you can close me with javascript."Code:<script type="text/javascript"> if(window.name!='prime'){ window.name='prime'; window.open(window.location.href, 'prime') } </script> <!--[if lte IE 6]> <script type="text/javascript"> window.opener=self; </script> <![endif]-->
This has the side effect of assigning the window the name of 'prime' (or changing its name to that if it had one). This could cause problems if you have any other code that relies upon the window's name being something else or null. But, this should be able to be worked around if it is at issue in your setup.
- John________________________
Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate
@ djr33
Thanks for explaining.
Thank you everyone.![]()
Bookmarks