Click to See Complete Forum and Search --> : Closing a Webpage
criplad
02-14-2003, 08:35 AM
I have created a webpage that detects the Flash player by opening another page using an *.swf file.
Is it possible to close the initial window (the one with the *.swf file) from the newly opened window, without any input from the user?
This is driving my crazy. Any help would be great!
Thanks.
You can close web pages with window.close(). However, if the page was not opened with javascript, a prompt will alert the users that the window is trying to close. It is a security issue.
So, if you have a popup window that you are trying to close the original window from, you would use something like this in your <head>
<script language="javascript" type="text/javascript">
window.opener.close();
</script>
criplad
02-14-2003, 08:46 AM
Ta pyro, that's great!
Works fine, but is there a way of doing it without having the dialog popping up? I'm trying to make it all seamless.
No. Like I said, unless the window was opened with javascript, the promp pops up for security puposes.
criplad
02-14-2003, 08:59 AM
OK, how about this:
I'm opening the window by calling the following function:
if(command == "launch_flash") {
window.open("home.html","","height=600,width=800","menubar=no","scrollbars=no","statusbar=no","toolbar=no")
}
If I put a window.close(); statement in this like so;
if(command == "launch_flash") {
window.open("home.html","","height=600,width=800","menubar=no","scrollbars=no","statusbar=no","toolbar=no")
window.close()
}
it closes the window but still brings up that security dialog. As it's being opened using JavaScript, is there a way of avoiding the dialog?
Thanks.
Originally posted by criplad
if(command == "launch_flash") {
window.open("home.html","","height=600,width=800","menubar=no","scrollbars=no","statusbar=no","toolbar=no")
window.close()
}
it closes the window but still brings up that security dialog. As it's being opened using JavaScript, is there a way of avoiding the dialog?With that code, you aren't closeing a window opened in javascript. You are opening a new window, and then trying to close the one that you are currently in, pressumably the window the users browsed to your site with.