Why is Firefox allowing disabling of confirmation boxes? - javascript

Running this example http://jsfiddle.net/yxzqY/ on Firefox on my Mac, about half the confirmation prompts appear with a "prevent this window from creating further dialogs" checkbox. I understand allowing users to disable alerts, but confirmation boxes are part of control flow- clicking OK or Cancel dictates the next sequence of events- and disabling them breaks an application.
I see plenty of applications that rely on confirmation prompts, and have never seen Firefox or any other browser doing this (witness trying to delete a question on StackOverflow)- so why is it occuring here? Why is it happening only sporadically? And how can we prevent it from happening at all?

As far as I can tell, the criterion for a "prevent further dialogs" checkbox is that the user has been presented with more than one dialog in a row within a short period of time (perhaps five seconds or so in current versions of Firefox; a second or two in Chrome).
The reason it's being added under these circumstances is to prevent malicious pages from tying the user up with endless sequences of dialogs:
while(1) {
alert("Is this annoying yet?");
}
If you expect that your application will be using a lot of confirmation dialogs like this, I recommend that you use a DOM dialog (e.g, http://jqueryui.com/demos/dialog/) instead of the native alert() or confirm().

Related

How to confirm closing browser window?

The question is
How to show a confirmation box on closing a browser window ?
This question has been asked many times before, and previous answers, such as https://stackoverflow.com/a/333673/1442181 suggest to use the onbeforeunload event.
But, according to http://developer.mozilla.org/en-US/docs/Web/Events/beforeunload, "browsers may not display prompts created in beforeunload event handlers unless the page has been interacted with, or may even not display them at all."
I have a preview page after the user has filled some form, and I would like to show a confirmation prompt when the user leaves the page (except by clicking "back to edit" or "submit"). The preview page cannot be interacted with, so previous solutions seem to not work e.g. in the current firefox version.
(How to avoid the prompt on these two links is not part of the question and answerred in detail elsewhere.)

Chrome issue when using jquery

Am using the confirm message when delete the record from the table.When I click and delete the records got "prevent this page from creating additional dialogs chrome".How to disable the prevent this page from creating additional dialogs in Chrome alert?
What are the chrome settings changes are required to disable the messages?I googled lot but no luck.
Thanks in Advance..
As others have said, this is a built-in safety net on Chrome (and other browsers, Firefox for example) that you can't work around (nor should you try). Its purpose is to prevent websites "locking" the page by repeatedly throwing alerts; for every alert you dismiss, a new one surfaces. It used to be the case that the whole browsers was "locked" until the alert was dismissed (try it in IE6).
At the risk of going Off Topic, I would be inclined to re-consider your approach: instead of asking the user to confirm an action, give them a means to undo it instead. More often than not, the "delete" action was intentional, so adding the extra interaction is likely to be a PITA for power users. Similarly, it's entirely likely people will become blind to the alerts and dismiss them without even reading them, such that they serve no purpose at all.
See: http://patternry.com/p=undo/ and Never use a warning when mean Undo
You can't. It's a behavior of the browser. It doesn't depend on JavaScript.
Its the default behaviour of Chrome. If you are showing frequent alert/confirm then it will show this, and the worst thing is if the user check h check box, no alert and confirm will be shown afterwards.
You can use Jquery Poup to show any message or get any data from users

disable onclick ads with a content-script in Google Chrome

There are some video streaming sites that pop up an ad anytime you click anywhere on the page. The problem is, you have to click on the page to press play! So I was thinking of making a UserScript that disables the script that does this. The only problem is, I already disable all the scripts on the site and when I do it still pops up. Is there a way that I can disable them ? I'm also using jQuery, so if I can do it through their interface, that would be great.
edit: Two perfect examples of such sites are daclips.in and gorrilavid.in
I have Adblocker Plus, and it seems like it is not recognizing "on Click" events as pop-ups, rather normal clicked links. And the logic is simple, no Adblocker will block you from clicking something intentionally and it (the link) opening in another window/tab.
The problem is the new window contains your clicked Url, while the original window/tab "Refreshes" (i.e. redirects) to another url.
Advertising companies seem to use this trick to bypass adblocking software.
Just ditch Chrome and use Firefox. Firefox already have built-in mouse-click popups. I think all addons like Adguard or Adblock can not disable mouse-click popups. If you use Firefox, these are the steps:
Type about:config in the browser's address bar and hit the enter key.
First time users need to confirm that they be careful on the next page.
Type or paste dom.popup_allowed_events into the search field.
The value of the preference highlights all events that are allowed to spawn popups.
Edit the value to remove some or all of the items here.
Why not just use a browser extension such as AdBlock?
https://chrome.google.com/webstore/detail/adblock/gighmmpiobklfepjocnamgkkbiglidom?hl=en
My go-to is right click and open in new tab. onClick events only happen with a left click. It's cumbersome but it still ends up being less work than closing the pop-up and whatever annoying prompts it may have.
I do not there's a practical solution for this.
Moreover, I think some of the answers here are missing the specific case in OP, where clicking anywhere on the page will cause the pop up to happen, not just clicking on links. According to this, neither right-clicking then choosing "open", nor noticing and blocking the target URL will help. I do not know of an add blocker that helps here either, because it's not trivial to meaningfully filter a click event that is taking place on the whole page object.
Only the solution provided by #Monkey would work, at the drawback of possibly breaking other things.

history.go(-1) behavior in different browsers

Does history.go(-1); behaves same in all browsers? I am seeing different behavior across various browsers.
My code contains a line similar to javascript:history.go(-1);
I have three check boxes in first page. User is allowed to select only two of them. If I select all three and hit submit then in next page, am doing javascript:history.go(-1); using a button saying error message that only two options are allowed. In safari when I come back to first page I see all three check boxes selected, but in firefox only two of them are selected. Chrome, Confirm Form Resubmission message to refresh the page
No, Browsers can act differently to histroy.go. How you interact with the browser before history.go can have different effects when it is called. To make cross-browser javascript is fairly tricky, but correcting the history issue should be fairly simple. I answered your only question, "Is this true?". It is likely you want to know how to fix the issue and that is specific to your code.

Required fields not met when closing window

I'm looking for the best way to go about "forcing" the user to fill a textarea.
For my work we have a system that keeps track of time spent on a particular "task". Some tasks are required to have a comment while others are optional. At the top of the page there is a timer, a textarea for the comments and a list of different tasks.
So far I have it so when the user tries to stop the timer, it won't stop until the comment is written (if it is required). When the paged is closed while the timer is running, an onbeforeunload function sends an alert warning that the comments aren't filled out and then the "Are you sure you want to leave?" warning pops up.
As far as I can tell there is no way to prevent the user from completely exiting the page. The idea we had was when the user closes the window, have another simple page open that just has a textarea and an instruction telling the user to write a comment. I'm pretty new to JavaScript and web development so I'm not entirely sure the best way to go about this.
Put that text area in a popup or iframe or modal window where you can control its closing.
On these window.close you can call the functions to validate the text area is filled or not.
Am not sure you can put that in a popup or not .but thats the only good way i can think of !!
There is no way to prevent the user from leaving a page.
Built in pop up blockers will also block the system from opening up popup windows onunload. Only way to allow onunload popups is if your system admins can update every browser to add an exception to the browser security settings.
It is impossible to make a web application act like a client application.

Categories