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.
Related
I want to have one same page open on multiple browser tabs. When I click on ONE browser tab, I want a JavaScript function to be executed ONCE, just one time! Not that that function is being executed 3 times because that one same page is opened on 3 browser tabs for example.
I have tried:
window.addEventListener("focus", () => {
console.log(document.hasFocus());
});
This works fine if your cursor is focusing on a web browser and keeps switching between tabs on that browser.
But if you first focus your cursor on something else other than that web browser (e.g. computer desktop or code IDE) and then you click on a NON-ACTIVE browser tab, the above code will be executed two times, one time by the previous active tab and another time by the new active tab you just clicked on.
That is my problem.
How can I execute JavaScript code only one time when I click on a web browser tab? Any solution besides JavaScript code is also welcome e.g. tracking pixels or input field autofocus event, just to name samples. I did not mean that tracking pixels techniques will help. I am not using jQuery. I am using VueJs.
You might want to use this ancient method and JS syntax, before you adopt it for your final coding style. Have some classic vanilla flavor. It never hurts.
document.body.onfocus = function(e){console.info(e.type)}
should work exactly as requested...
but since this behavior is somewhat tied to the BOM, some browser vendors (with idiosyncratic behaviors) might require some sort of enforced filtering, Opera comes to mind.
But it should be rock solid on all modern browsers including a bonus backward compatibility, as back as Windows 98 browser version. And\or the ancient and now probably forgoten NN 4.7. ( except for the console info event log, but that's not needed for the actual use anyway )
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
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().
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.
Is there anything particular to chrome or safari that would make a javascript/jquery script work on the first page load, but then when the user hits the back button after navigating the site, it causes select boxes to be selected?
Here is the code. Apologizes before hand for the lack of conventions. I had to get this up quick:
http://www.mailcanarias.com/index.php
I believe that's because (at least Safari) auto-refills forms when you go back