Solved

to disable refresh icon of browsers

Posted on 2009-04-14
4
908 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
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

I have developed many web applications with asp & asp.net and to add and use a dropdownlist was always a very simple task, but with the new asp.net, setting the value is a bit tricky and its not similar to the old traditional method. So in this a…
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…
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…

910 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now