Question

Hello I am wondering if i can have the unload method in javascript do a button.click; or a document.getElementById('target').click();

The reason for this is I want to clear the information in the broswer but I can't seem to get the unload method to work right. But I don't even know if the unload method is capable of doing a button.click or a document.getElementById('target').click(); Is there like a list of things this method can or cannot do? here is the code I am trying to get working.

  window.onunload=leave;

     function leave() {
//alert("Leaving");
    document.getElementById('kioskform:broswerCloseSubmit').click();

}

The alert seems to be showing in everything ("IE, FireFox,Safari") but in chrome ('don't know why) but i can't seem to get the clear options i am using to work with the unload method. Not to mention I am wondering if there is a good way to detect which broswer the individual is using to load in different parts of the unload script any idea's or suggestions or advice is greatly appreciated thank you.

Was it helpful?

Solution

If you were to use jQuery , you could use the DirtyForm plugin. This would accomplish what you are trying to do.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top