Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

I want to stop the browser request, when user clicks on any button from UI, like stop button on browser

Tags:

javascript

I want to stop the browser request, when user clicks on any button from UI, like stop button on browser. I want to do it through javascript.

like image 390
Mannusanghi Avatar asked Aug 17 '09 07:08

Mannusanghi


People also ask

How to make your browsers Stop Bugging you on Windows?

Here’s how to make your browsers stop bugging you on Windows. Google Chrome displays a small message at the top asking you to make it your default browser. Unfortunately, there’s no option anywhere in Chrome to get rid of this message for good. However, you can click “X” on this default browser prompt to dismiss it.

How to stop Firefox from asking to be the default browser?

On Firefox’s Options screen, click “General” on the left. Deactivate the “Always check if Firefox is your default browser” option on the right. Firefox will stop asking to be your default. Stop Microsoft Edge from Asking to Be the Default Browser

Is the refresh button or back button clicked on the browser?

But there is a problem that identical events can occur once a user clicks on the refresh button of a browser. So, to grasp whether the refresh button or back button is clicked, we will use the subsequent code. alert ("Browser back button is clicked..."); alert ("Browser refresh button is clicked...");

How to disable the Ctrl+F5 button on the browser?

You can disable the ctrl+f5 and only f5 button/keypress using javascript. Below are few links you can follow up with:- 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.


1 Answers

As Amit Doshi and Slaks code suggests you can do that. But I find it more efficient to do a try and catch.

There is only one alternative to window.stop() so trying it first with a fallback (for Internet Explorer) is the way to go to support all browsers:

try {
    window.stop();
} catch (exception) {
    document.execCommand('Stop');
}
like image 193
Jose A Avatar answered Oct 15 '22 08:10

Jose A