Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

OnUnload question

Status
Not open for further replies.

ts2032

Technical User
Mar 26, 2002
115
US
I have a function that runs on the onUnload event..

when I refresh the page the function executes correctly, However, when I click the back button, the function begins to execute(I have set up alerts throught the function) and appears to get.

the function calls the click event of a button...

document.all.savechanges.click()

I put an alert in the onclick() event of the button. When you go back, it does not fire. When you refresh everything works fine. Is this an IE bug. below is my function.

function saveall(){
if(total !=0){
if(confirm("do you want to save")){
//alert here works fine
document.all.savechanges.click(); //for some reason this does not work
//alert here works fine
return false;
}

}
}
the variable total is set within the page

any help or comments would be appreciated
tsmith
 
I remedied the problem by adding this to the onBeforeUnload event of the body

onbeforeunload="if(total != 0){return 'You have changes that have not been saved.'}"

and removing the onUnload event and the save() function

still wonder about the above though,

tsmith
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top