Saturday, November 10, 2012

JavaScript is platform dependant

I am feeling so bad on this issue, but I have no choice. When requirement come into my hand, I must get it done. Majority of my development was done on IE, and the initial requirement was targeted on IE as well. When requirement change request to target on other browser like Firefox, Safari, Google Chrome, and Opera, I am required to get the job done as well.

Initially I though everything should be fine, but eventually it is not where the unload event doesn't support in Firefox. Some suggest me that I should use onbeforeunload in Firefox. I had tried it and it's really work. Below is the code snippet on how this could be done.

Here I made the 2nd mistake, once I put in the code snippet, and I forgot to remove this code unload="onUnload()" from body tag. This end up the page sending the request twice to the server during unload event. Thus it is advisable to take it out if the code snippet exists.

But one bad news is Opera doesn't support onunload and onbeforeunload at all.

No comments: