I have an HTML page that is broken up into two different frames. The left frame acts as a navigation tool. The right frame is the user interface, which consists of a form with different input types. I want to track when a field has changed so I can prompt users if they try to navigate away from this page using the left frame. I can track the changes by using an onchange event, but I can’t seem to trap when they leave the page. I have tried the using the onblur for the page and the window, but I can’t seem to get it right.
You can track when the person tries to navigator to another page, either at frame or window level, using the “onUnLoad” event handler. Use this code in the body tag for a page:
or within a frameset:
Note, though, that the onUnLoad event won’t work with browsers that don’t support Navigator JS 1.1 or higher. However, it should work with Navigator 3.x and up, and IE 4.x and up.