...

View Full Version : JavaScript function for Refresh button



tspraveena
05-02-2008, 04:57 AM
hi,
Is there any javascript function to find out F5(Refresh) button is pressed?

Any help would be very much appreacited!.

binaryWeapon
05-02-2008, 05:46 AM
function ProcessKeypress(e)
{

if (e.keyCode) keycode=e.keyCode;
else keycode=e.which;
if(keycode==116)
{
return true;
}
else
{
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);">

tspraveena
05-19-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?

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

if(!e)
e=window.event;
// then rest of code

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



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum