Solved

to disable refresh icon of browsers

Posted on 2009-04-14
4
1,004 Views
Last Modified: 2012-05-06
can we disable the refresh icon of browsers? Am able to stop refresh  by disabling F5 but i want to disable refresh icon.Help me out plzzzzz
0
Comment
Question by:mannevenu
[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 10

Expert Comment

by:stormist
ID: 24145059
There is no way whatsoever to do this, short of malware.

Sorry
0
 
LVL 12

Expert Comment

by:Nirmalan Nagenthiran
ID: 24145060
0
 
LVL 18

Expert Comment

by:Ajay Sharma
ID: 24145083
There is no way of disabling any of the browser buttons or menus using java script.

As the browser is a software on the client's machine so you cant control a software on a visitors computer from your web application or java script.

If this would be possible then any attacker can easily control your system from web.

If you want that user should not be shown the browser buttons controls then you can open your page in a pop-up window (and while opening the pop-up page set the toolbar property to false from the calling page).
0
 
LVL 14

Accepted Solution

by:
GiftsonDJohn earned 500 total points
ID: 24145127
Hi,

http://www.gklein.org/tests/js/disablekey.html

It is not possible to disable the refresh button on the browser but you can prevent the user from hitting the F5 key.

Just copy the code to a javascript file and refer the file by <script type="text/javascript" src="<path>"> </script>

On the Submit button click event after you have updated the values into the database include the following code snippet.

Page.ClientScript.RegisterClientScriptBlock(btnSubmit.GetType(),"DisableKey", "setEventListener(disableKey)",true);

If you really want to filter out whether the user clicked the refresh button on the browser, what you have to do is to preserve a hidden value with some GUID when the page is loaded first time before hitting submit. You can validate with the GUID field after the submission by storing the value into some cache.
function disableKey(event) {
  if (!event) event = window.event;
  if (!event) return;
 
  var keyCode = event.keyCode ? event.keyCode : event.charCode;
 
  //window.status = keyCode;
  //alert(keyCode);
  
  // keyCode for F% on Opera is 57349 ?!
  
  if (keyCode == 116) {
   window.status = "F5 key detected! Attempting to disabling default response.";
   window.setTimeout("window.status='';", 2000);
 
   // Standard DOM (Mozilla):
   if (event.preventDefault) event.preventDefault();
 
   //IE (exclude Opera with !event.preventDefault):
   if (document.all && window.event && !event.preventDefault) {
     event.cancelBubble = true;
     event.returnValue = false;
     event.keyCode = 0;
   }
 
   return false;
  }
}
 
function setEventListener(eventListener) {
  if (document.addEventListener) document.addEventListener('keypress', eventListener, true);
  else if (document.attachEvent) document.attachEvent('onkeydown', eventListener);
  else document.onkeydown = eventListener;
}
 
function unsetEventListener(eventListener) {
  if (document.removeEventListener) document.removeEventListener('keypress', eventListener, true);
  else if (document.detachEvent) document.detachEvent('onkeydown', eventListener);
  else document.onkeydown = null;
}

Open in new window

0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

I recently went through the process of creating a Calendar Control of events with the basis of using a database to keep track of the dates that are selectable, one requirement was to have the selected date pop-up in a simple lightbox.  At first this…
Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

732 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