?
Solved

how to cancel onunload or onbeforeunload event?

Posted on 2003-03-28
4
Medium Priority
?
2,905 Views
Last Modified: 2012-06-27
I want to be able to check if F5 is pressed, so that I can cancel refresh and call another function..

I tried with:

document.onkeydown = checkRefresh;

function  checkRefresh(){
    if (event.keyCode == 116) {
        myRefreshFunction();
        event.returnValue = false;
        return;
    }
}

but, myRefreshFunction() is not called and refresh still happens?!
0
Comment
Question by:mileage
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 7

Expert Comment

by:cubrovic
ID: 8227018
What is in myRefreshFunction.
Maybe problem is there.
0
 
LVL 4

Accepted Solution

by:
jonnal earned 300 total points
ID: 8227315
try


function  checkRefresh(){
   if (event.keyCode == 116) {
       myRefreshFunction();
       return false;
   }
}
0
 
LVL 16

Expert Comment

by:jaysolomon
ID: 10150147
No comment has been added lately, so it's time to clean up this TA.
I will leave the following recommendation for this question in the Cleanup topic area:

Accept: jonnal {http:#8227315}

Please leave any comments here within the next seven days.
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

jAy
EE Cleanup Volunteer
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses how to implement server side field validation and display customized error messages to the client.
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question