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". :)
Related
My Mobile Web Application has an option to enter the developer settings by clicking 6 times in a row on app logo on the top of the display.
Procedure is almost identical to enabling developer settings on Android.
After clicking 6 times, an alert opens up with the information about developer settings being enabled.
However, when a developer wants to enable those settings, he clicks on the logo without counting. The alert window is dismissed almost instantly since it appears after 6 clicks; but 7th click comes really quickly after 6th so the developer can't see the alert appropriately.
How can I make the alert window not dismissed after clicking outside of it? So the developer actually has to press 'OK'?
Simple, you cannot...
You have to emulate this behavior with a DOM Dialog
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."
I'm trying to open the Chrome inspector to see the console log and I can't.
It works very well with Firefox but not with Chrome.
The chrome development tools is enabled and works well when there is no prompt or alert pop up running.
I have a little program in which I have a prompt that asks the user to give a number.
Explanations for the user are in the console(console.log("xxxx")), so when the page is loaded and the prompt is on the screen, the user would have to open the inspector window to see what choice he/she should make.
Here is my code:
console.log("1\n2");
var saisie = prompt("What is your choice");
alert(saisie);
I would like the user to see the console log before they answer the prompt.
You can use window.console to access and interact via javascript with the debug console. Then you can pipe its contents to a div on the page.
alert is blocking, which is why people tell you not to use it (or leave snarky comments to that effect). 'Blocking' means that nothing else can happen: it literally hijacks the entire tab. Meaning that you can't, say, open chrome devtools without dismissing the alert first. I have no idea how this is actually working in FF.
Pro-tip: don't ever use alert. Ever. Use a modal dialog, iframe, whatever. Don't use alert.
I've got a very basic HTML page, which only has to show a javascript alert.
I hear the sound that it's supposed to make when it pops up, but it's not popping up! I don't see it anywhere (in google chrome it does pop up). I also can continue working on my page without clicking "ok" on the (invisible) alert box, so that means that it really isn't there!
Any clues on how to solve this? I already rebooted my pc and disconnect my multiple monitors.
<script>
alert('SHOW!!');
</script>
More info:
My IE version is IE11
The popup did work properly before, without making changes to IE
On other websites, the popup isn't showing aswell
I did reset my IE properties (to factory default), no result
unable to test on older versions
Javascript is enabled
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