Jump to content

onUnload


smartino
 Share

Recommended Posts

Hi Javascript guru's,I don't know if this possible as i'm a newbe to Javascript. When someone uses the X in the top right of any window I want to send a command to a page on my server when the window closes.At the moment I'm using onUnload and the javascript seems to be working with a simple alert in it. The page on the server has update commands in it to update a database but the database isn't being updated on the window closing!?!?Thanks in advance for any help.Simon.

Link to comment
Share on other sites

you can't update a datbase with JavaScript.what is the code that is being executed on onunload? Can you post your code?

Cheers for the reply - I'm trying to send a request to another page on close of the window. Inside that page I have code to update a database. Like I say, abit of a newbie on this and not sure if it's possible. Below is the onunload...<script language="javascript" type="text/javascript"><!--var IE = document.all?true:false;function HandleOnClose() {if (IE){ if (name){ window.location.href="goupdate.cfm?<cfoutput>#URLTOKEN#</cfoutput>" } } else { window.location.href="goupdate.cfm?<cfoutput>#URLTOKEN#</cfoutput>" }}//--></script>
Link to comment
Share on other sites

is the update page actually getting loaded? If so then the database updating is a problem with the update page not the page that redirects to the update page.

The page isn't getting loaded and I believe that is my problem. I know the update works if the page is run. I need a method on close to run a page on my server even though the user closes their window. I could open another window then close it but I'm facing a problem with pop-up blockers!Can I call a Javascript/Function on another page that is in a window below the window that the user is closing and if so how do i do this?
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...