Click here to Skip to main content
14,922,433 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi all!,

I want to disable refresh button of all browser or I would like show there custom message in div. Please provide solution whether in Server side or client side.
Posted
Updated 25-Dec-19 20:26pm
Comments
syed shanu 4-Dec-14 2:40am
   
use google before asking questions .There is lots of samples available from google.Check few links.
http://www.aspsnippets.com/Articles/Disable-F5-Key-Button-and-browser-refresh-using-JavaScript-or-jQuery.aspx

http://stackoverflow.com/questions/2482059/disable-f5-and-browser-refresh-using-javascript

http://www.dotnetfunda.com/forums/show/12128/how-to-disable-refresh-button-on-browser-using-javascript
Sri Nitish 4-Dec-14 3:17am
   
Dear Mr. Syed..... I had used google but solution is same that you provided but that's not my need coz they providing solution for F5. But I want to disable either refresh button or display my custom message in div.

Best solution is to open your Page with no Toolbar.
C#
window.open ("yourPageURL","mywindow","status=1,toolbar=0");
   
Comments
P Nagendra11 26-Dec-19 2:27am
   
Please give suggestion for this " window.open ("yourPageURL","mywindow","status=1,toolbar=0")"
yourPageURL value will like this "https://www.google.com"
mywindow what will be the of value ?- Any one tell this value for this Thank you
You can disable the ctrl+f5 and only f5 button/keypress using javascript. Below are few links you can follow up with:-
Disable Refresh[^]
Disable Refresh 2[^]
But dear disabling the refresh icon on the browser is next to impossible. Like disabling the back button we manipulate with the browser history. But We cant manipulate with the browser defaults.
I hope this helps you.
Post back your queries if any.
Thanks.
   
Comments
[no name] 4-Dec-14 2:50am
   
Thanks a lot Tadit . :)
Sri Nitish 4-Dec-14 3:13am
   
Thanks!

Here I am trying to show message in dialog (div) when user try to refresh on 'onbeforeunload' as below

$(window).on('beforeunload', function (event) {
return Show();
//return '>>>>>Before You Go<<<<<<<< \n Your custom message go here';
});

function Show()
{
$('#div').dialog({ modal: true });
}
but this not working properly coz pege getting refreshed.
[no name] 4-Dec-14 3:18am
   
Did you check in the developer tool debugging if the script is working as t should?
[no name] 4-Dec-14 3:20am
   
http://stackoverflow.com/questions/14645011/window-onbeforeunload-and-window-onunload-is-not-working-in-firefox-safari-o
Check this. It says beforeunload doesnot work in all browsers.
This has a solution try out with that.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900