?
Solved

to disable refresh icon of browsers

Posted on 2009-04-14
4
Medium Priority
?
1,112 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 2000 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

Independent Software Vendors: 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

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…
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

752 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