Posts [ 1 ]

Topic: Using the JavaScript onUnload event

Hey guys, got a general JavaScript question. I am trying to get the onUnload event working in a page.

I have been tasked with modifying a PHP script I wrote 2 years ago, that handles contact off our school's website from prospects (potential students).

Well they don't want to use databases at all (at least yet), so they want it so even if someone never submits the 2nd page of this form, an e-mail is sent to or call center.

To make a long story short, I am using onUnload to call a JavaScript function I created that I am calling a PHP function using document.write, and then it also calls an alert(). The problem is, when I am testing this, and close this 2nd page, nothing happens, so obviously the onUnload event is not being triggered.

My main question is, can onLoad and onUnload be used at the same time on a page? I tried googling it, but all the results I got had nothing to do in context of what I was seeking.

The code I am working with on the main part of the pages is so badly formatted it's not even funny. Before I came back to the company, they contracted this job to some company that used FrontPage to build the new version of the site. (shoot me now I know! ) But my boss said I can't change the html any, so I'm at a loss there, but none the less, the js should still function.