Solved

to disable refresh icon of browsers

Posted on 2009-04-14
4
1,047 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

Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

Question has a verified solution.

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

Lots of people ask this question on how to extend the “MembershipProvider” to make use of custom authentication like using existing database or make use of some other way of authentication. Many blogs show you how to extend the membership provider c…
One of the pain points with developing AJAX, JavaScript, JQuery, and other client-side behaviors is that JavaScript doesn’t allow for cross domain request for pulling content. For example, JavaScript code on www.johnchapman.name could not pull conte…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

695 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