By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,165 Members | 850 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,165 IT Pros & Developers. It's quick & easy.

window.onbeforeunload: how to change the message? and is preventing cache?

P: 3
Hi,

I want to confirm if the user wants to exist the page without any save. my code:

Expand|Select|Wrap|Line Numbers
  1. <script language="javascript" type="text/javascript">
  2.  
  3. window.onbeforeunload = confirmExit;
  4.  
  5. function confirmExit(){ 
  6. return 'Exit without save';
  7.  
  8. }
  9.  
  10. </script>
  11.  
This works well, But the message that is shown contains the default message of the IE how can I show only my text in the confirm popup?

without:"Are you sure you want to navigate away from this page?" and

"Click OK to continue, or Cancel to stay on the current page."

Another thing, Is it true that if I add the window.onbeforeunload event hander to my page it will never be cached and allways be reload?

Thanks.
Feb 4 '08 #1
Share this Question
Share on Google+
1 Reply


acoder
Expert Mod 15k+
P: 16,027
This works well, But the message that is shown contains the default message of the IE how can I show only my text in the confirm popup?

without:"Are you sure you want to navigate away from this page?" and

"Click OK to continue, or Cancel to stay on the current page."
That's the default and there's no way to change it.

Another thing, Is it true that if I add the window.onbeforeunload event hander to my page it will never be cached and allways be reload?
I don't think so. It doesn't prevent caching as far as I'm aware.
Feb 4 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.