Solved

to disable refresh icon of browsers

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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Javascript newbie 5 38
Hangfire / asp.net sample 3 27
send mail from app.net 8 28
Cannot upload files above 1mb IIS7 11 0
User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

707 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

16 Experts available now in Live!

Get 1:1 Help Now