Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

can this code be made more simple? 2

Status
Not open for further replies.

PantherRun

Technical User
May 18, 2004
100
0
0
US
Hey out there;
Oldnewbie gave me this code to close a movie window and return me to my base web page...

on (release) {
getURL("javascript:window.close();");

}

It works great, but everytime this code is triggered a pop up window snaps up saying "so an so is trying to close a window, proceed, yes or no, ect.", sort of thing.

Is there a version of this code that will JUST CLOSE the window and not ask for input from the reader?

Hoss
 
This will always occur on attempting to close the user's main browser window (if it's the only window opened...), but not when closing a popup or attempting to close the main browser window, once another window (popup or not...) has been openened.

That said, I have manage, some time ago, to close the main browser window without the warning... It worked on some versions of IE, but did not on others and/or other browsers... Looking for that script, but find it just now...



Regards. Affiliate Program - Web Hosting - Web Design
 
Can i follow up here with something. You said "This will always occur on attempting to close the user's main browser window (if it's the only window opened...), but not when closing a popup or attempting to close the main browser window, once another window (popup or not...) has been openened."

Now what i have is a map web page (main browser window?) and on this page sits 5 movies, click on the movie and it will open into its own window, thus becoming the 2nd window opened. So if I'm reading you right, that warning box shouldn't be popping up on the 2nd window opened as I try to close it, (It should only be popping up if i were trying to close out the map (main browser) window?

I'm not understanding this right?

 
Your understanding is correct. The basic rule is if you created the page you can destroy the page without a warning. With SP2 and other blockers etc.. out there all bets are off.

To expand on what Oldnewbie gave you here is a code that has always worked for me. (null is the biggest difference.)

Add this javascript function to the HTML page that contains your Flash movie.

Code:
<script language="javascript">
function cmdExit(){
	window.parent.opener=null;
	window.parent.close();
}
</script>

Then it would be:
Code:
getURL("javascript:cmdExit()");

Keep in mind that both of these methods will fail if javascript is disabled on the client computer.

Hope it helps.

Wow JT that almost looked like you knew what you were doing!
 
Please, please excuse my ignoranace, but I'm a little lost here. Thanks for this help, I just don't know how to use it. Here's what i did and as you'll see, the debug function was not happy.

on (release) {
function cmdExit()
window.parent.opener=null;
window.parent.close();

}
getURL("javascript:cmdExit()");

Would you please arange this so it will function. Also i will have this on a button within a flash movie, but that doesn't make any difference right?

Hoss
 
Afriad you didn't follow the instructions Hoss. :)

The javascript goes in the HTML page that contains the Flash movie. Once that is done your button function is:
Code:
on(release){
   getURL("javascript:cmdExit()");
}

Hope that helps.

Wow JT that almost looked like you knew what you were doing!
 
Ahhhhhhh... got it, this is something my webmaster will have to do! Okay, i'm there, thanks, you two.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top