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 browser 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 browser the individual is using to load in different parts of the unload script any idea's or suggestions or advice is greatly appreciated.
If you were to use jQuery
, you could use the DirtyForm
plugin. This would accomplish what you are trying to do.