Link to home
Start Free TrialLog in
Avatar of Mazen
Mazen

asked on

Cancel Refresh

Dear all,

  How can I cancel the refresh button from the explorer for a certain page?

    Thanks,

    Mazen
Avatar of knightEknight
knightEknight
Flag of United States of America image

what do you mean by cancel?  do you mean disable it so that it can't be clicked?  you can't do that.
generally, it's a bad idea to mess around with the standard i.e. user interface .. a common question is "How do I disable the back button?"

The correct answer, however, is not to disable it, but rather to see what your problem is (i.e., why do you want to disable it in the first place??) and fix it from there.  

So, I answer a question with a question -- why do you want to disable the refresh button?

regards,
peh803
Avatar of Mazen
Mazen

ASKER

Thanks, I found the solution

<script language="JavaScript1.2">

if (document.all){
document.onkeydown = function (){
var key_f5 = 116; // 116 = F5

if (key_f5==event.keyCode){
event.keyCode = 27;

return false;
}
}
}


   I'll delete this question.

       Mazen

</script>
Avatar of Mazen

ASKER

I am sorry I didn't see your comments. if you have any questionss, let me hear them before I ask the moderators to delete this question.


         Mazen
you can delete it ... but I am curious about the code you posted.
It looks like it will disable the F5 key, but I don't think that will prevent anyone from clicking on the refresh button with the mouse -- am I right?
@knightEknight:

yes, that is correct, this only cancels F5 refreshes.  Users could still right click --> refresh from contextual menu, click the refresh button in the toolbar, or click the "refresh" option from the "view" menu.

peh803
A wild guess suggests that Mazen is trying to build some kind of flooding protection, otherwise I cannot find any use for this script?
Avatar of Mazen

ASKER


   I have actually cancelled the right click from the page and I am opening the page as full screen (actually a requirement for my application), so basically I have prevented the user from refreshing the page unless I want to do so.  Your guesses are some how right, what I am trying to do is preserve the information in the page. If the user refreshes, then the data will be lost in my browser. I know I could save my variables in the session, but refilling the variables again is very messy so I was thinking of disabling refreshing as an alternative.

  Thank you all for your comments,

          Mazen
Mazen,

If a page is full-screen, can't you just hit F11 to toggle full screen to regular?  
When this happens, a refresh toolbar icon will be available.
If you've successfully disabled the F5 key, it makes sense that you could add your F11 button to the list.
Big deal. I can do a <Ctrl> + N (to open a new window) and then click on REfresh.

The lesson: Disable <Ctrl> + N as well...
you can use onunload even in body, but this only executes code that's inide and refreshes the page that's as far as you can go...
Avatar of Mazen

ASKER

My application is actually HTA, so I prevented the toolbar from appearing and I cancelled all events with CTRL, but I had this small problem with the F5 button, I was only missing the code I posted above. Thank you all for your suggestions.

    Mazen
ASKER CERTIFIED SOLUTION
Avatar of ee_ai_construct
ee_ai_construct
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial