admin管理员组文章数量:1291037
I try to understand Firefox's behavior regarding the added "prevent this page from creating additional dialogs" on dialog boxes.
Using jquery, if I add the following listeners :
//html
<input class="testInput" />
//javascript
$('.testInput')
.click(function(){ alert('clicked') })
.keyup(function(){ alert('keyup') })
- When clicking on the input, the alert box appears normally, until the ~13th time.
- When hitting a key, on the other hand, the second message box already appears with the message "prevent this page from creating additional dialogs". Actually, there seems to be some tiemout, and if I wait like 2 seconds between two keystrokes, the message disappears.
From my informal tests, 2.
actually applies whenever the alert box is not called from within a onclick callback (e.g : keyup callback, displaying an alert box in answer to an ajax action...)
I am using Firefox 9.0.1 under Ubuntu, as far as I know I haven't tweaked firefox's settings regarding these thresholds. I imagine it happens with any recent version of any browser.
I am using the jQuery library, but I don't think it is relevant here.
My question is : What are the exact rules which make this warning appear in a dialog box ?
[Edit]
Using Chromium/Ubuntu (version 17.0.963.26), the threshold seems to be only the delay between two dialog boxes.
You can test this from jsfiddle here (thx Rory McCrossan)
I try to understand Firefox's behavior regarding the added "prevent this page from creating additional dialogs" on dialog boxes.
Using jquery, if I add the following listeners :
//html
<input class="testInput" />
//javascript
$('.testInput')
.click(function(){ alert('clicked') })
.keyup(function(){ alert('keyup') })
- When clicking on the input, the alert box appears normally, until the ~13th time.
- When hitting a key, on the other hand, the second message box already appears with the message "prevent this page from creating additional dialogs". Actually, there seems to be some tiemout, and if I wait like 2 seconds between two keystrokes, the message disappears.
From my informal tests, 2.
actually applies whenever the alert box is not called from within a onclick callback (e.g : keyup callback, displaying an alert box in answer to an ajax action...)
I am using Firefox 9.0.1 under Ubuntu, as far as I know I haven't tweaked firefox's settings regarding these thresholds. I imagine it happens with any recent version of any browser.
I am using the jQuery library, but I don't think it is relevant here.
My question is : What are the exact rules which make this warning appear in a dialog box ?
[Edit]
Using Chromium/Ubuntu (version 17.0.963.26), the threshold seems to be only the delay between two dialog boxes.
You can test this from jsfiddle here (thx Rory McCrossan)
Share Improve this question edited Jan 13, 2012 at 13:39 LeGEC asked Jan 13, 2012 at 13:26 LeGECLeGEC 52.2k5 gold badges67 silver badges125 bronze badges 5- 1 FYI: testing with this fiddle (jsfiddle/RoryMcCrossan/9XwTn) I get the checkbox in the alert on the 12th iteration for both click and keyup. – Rory McCrossan Commented Jan 13, 2012 at 13:33
- @Rory : I still have my behavior. What browser do you have ? thx for the jsfiddle link. – LeGEC Commented Jan 13, 2012 at 13:37
- Just to fill in with some more data input; I get it on the 12th click iteration and 2nd keyup iteration on FF 9.0.1 Windows XP SP3. – Jeff Wilbert Commented Jan 13, 2012 at 13:40
- @LeGEC sorry forgot to mention browser, FF9.0.1 on W7 Pro x64 – Rory McCrossan Commented Jan 13, 2012 at 14:41
- How to reset this ? Now I want the dialogs again ! – TheMaskedCucumber Commented Jan 22, 2014 at 13:24
2 Answers
Reset to default 6The exact rule(s): A timed interval between the dialog boxes popping up. The value used to determine this is set in SUCCESSIVE_DIALOG_TIME_LIMIT
Check out line 2614 in the link below the snippet:
nsGlobalWindow::DialogOpenAttempted()
TimeDuration dialogDuration(TimeStamp::Now() - topWindow->mLastDialogQuitTime);
if (dialogDuration.ToSeconds() < Preferences::GetInt("dom.successive_dialog_time_limit",SUCCESSIVE_DIALOG_TIME_LIMIT)){topWindow->mDialogAbuseCount++;return (topWindow->GetPopupControlState() > openAllowed || topWindow->mDialogAbuseCount > MAX_DIALOG_COUNT);}topWindow->mDialogAbuseCount = 0; return false;}
Link to source
You can kick around the Firefox source if you like. Note that different browsers will have different rules.
The relevant code for Firefox is in nsGlobalWindow.cpp
and nsGlobalWindow.h
(the links below are to line numbers, and so will slowly rot as the source changes). It appears to be controlled by the constants MAX_DIALOG_COUNT
(10) in nsGlobalWindow.h
and SUCCESSIVE_DIALOG_TIME_LIMIT
(3, units are seconds). nsGlobalWindow.cpp
keeps a count (mDialogAbuseCount
). Apparently, the dialogDuration
function either increments or clears mDialogAbuseCount
depending on whether the dialog has been open longer than the SUCCESSIVE_DIALOG_TIME_LIMIT. The AreDialogsBlocked
function uses the mDialogAbuseCount
(in part) to decide whether they're blocked.
So in short: If you're repeatedly opening pop-ups and then closing them within three seconds, after 10 or so you'll trigger something.
本文标签: javascriptrules for quotprevent this page from creating additional dialogsquotStack Overflow
版权声明:本文标题:javascript - rules for "prevent this page from creating additional dialogs" - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741503600a2382189.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论