View Full Version : JavaScript function for Refresh button

May 2nd, 2008, 04:57 AM
Is there any javascript function to find out F5(Refresh) button is pressed?

Any help would be very much appreacited!.

May 2nd, 2008, 05:46 AM
function ProcessKeypress(e)

if (e.keyCode) keycode=e.keyCode;
else keycode=e.which;
return true;
return false;

That function would return true if the user hit f5, and false if the user didn't. You would call it in the body tag like: <body onkeypress="ProcessKeypress(event);">

May 19th, 2008, 02:43 PM
No this script is not working. please can you check this?
Please try it once and let me know.

I can't able to run this script in

<body onkeypress="ProcessKeypress(event);">

There is framework outside and i have to work in middle of this framewwork,
Anyway onloading the file i can able to call this script.
it didnt worked.
I was given some alert there, it says undefined for the value of keycode.
any idea?

May 19th, 2008, 03:07 PM
I believe you need to check the existence of event object(in some browser) within the function like

// then rest of code

Philip M
May 19th, 2008, 04:53 PM
Surely most people simply click on the refresh icon.