How to prevent Google chrome from suppressing confirm() dialog - javascript

the new version from google chrome does not allow confirm dialog if the window is not active.
I have a page which is calling a popup. The popup has a button. on click of that button, a javascript function of parent page will be called . the javascript function has a confirm dialog.
after chrome update to Version 69.0.3497.100 (Official Build), this is not working any more with following warning.
"A window.confirm() dialog generated by this page was suppressed because this page is not the active tab of the front window. Please make sure your dialogs are triggered by user interactions to avoid this situation. https://www.chromestatus.com/feature/5140698722467840"
try this [jsfiddle]: https://jsfiddle.net/VikasUpadhyay/47vurfm0/6/

Related

Why does alert box closes automatically on Chrome tab (window) change?

Whenever a normal alert box displays on a Chrome tab, it disappears when you switch the tab (ok is triggered automatically). Not the same behaviour on Firefox. I am wondering why? Didn't find any answers... Thanks.
Duplicate? Javascript : Alert Box dismissed when tabs switched
From Google: "This is working as intended, see Issue 629964 . It's not a security bug; a user could make the dialog box disappear with developer tools or myriad other tricks as well."

Javascript : Alert Box dismissed when tabs switched

How not to allow Alert Box to be dismissed when tabs switched.
Using alert("Test"); on Google Chrome, when you switch tabs, the alert dialog box disappears, and when you're back on the same tab you have full access.
What I want is to do the same thing as stackoverflow website when you create a question and try to close the tab, there's a dialog box that pops up that doesn't allow you to go anywhere until you choose between (Leave or Stay).
IE and Firefox work differently, I mean block the tab when using alert("Test"); statement but Google Chrome doesn't block.
I sent a bug report to Google but they replied to me that :
This is working as intended, see Issue 629964.
It's not a security bug; a user could make the dialog box disappear with developer tools or myriad other tricks as well.
I was able to get around this issue by calling my javascript alert in an iframe
I would like to point out that this appears to have reached a compromise; current (Version 110.0.5481.104 (Official Build) (64-bit)) shows alert() and confirm() on the tab, but do not prevent going to another tab.
When user returns to the original tab - the message box is still there waiting for them.
So this allows persistence, without "hijacking the browser". :)

How do i avoid Chrome to display the confirmation message before close the window?

I have an iframe (a google drive form) in my site. When i try to move to another page, the browser shows a message to confirm if i "want to close the window, its possible to lost the changes made".
I am using a javascript, and works on mozilla but not in google chrome
function cierra_ventana()
{
window.open('','_parent','');
window.close();
}

OnUnload not working in chrome and opera

I know there are many links regarding Onbeforeunload,BeforeUnload and Onunload events of JavaScript which have some cross browser problems. After going through, possibly, all the questions, I want to ask this again
Is there any way so that onunload can work for Chrome and Opera?
I don't want to use onbeforeunload as it pops up before closing window.In my application user clicks a "Save And Exit" button after which an alert box is popped up showing "Your details are saved" with OK button. clicking on OK button redirects user to a new popup asking the window is about to close with yes and no buttons. onbeforeunload event as returns a string, hence it doesn't allow me to show the "AlertBox" asks for leave this page and stay on this page. which is not in alliance with my application requirement as i want as alert box. (working fine in IE, not working in Opera and chrome).
i am using unload and onbeforeunload events from code behind c#

Process Javascript in inactive tab on iPad

I have this solution that takes the user through a series of questions. At the end the user can click a button that opens a new window with a form to enter contact info. The population of this popup window is done through JavaScript from the calling window.
The process (in JS) is this:
Open popup window with loading gif
Store additional information remotely through ajax
Populate popup window with contact form
This all works fine in desktop browsers but not on iPads (using Safari where all windows are displayed as tabs). I have a suspicion that the JavaScript in the parent tab is halted when the "popup" tab gets displayed. To support this theory I can actually get the popup tab populated if I switch back to the parent tab immediately after the popup tab is displayed.
Can anyone confirm this? And of course if there's a solution I would very much like to hear about it.
Needless to say it works like a charm on my Android tablet :-)
Try using window focus and blur to activate some javascript when the focus is back on your tab.
See: https://stackoverflow.com/a/3479936/1712686

Categories

Resources