Dan*_*ett 31 javascript google-chrome
我正在开发一个利用JavaScript alert()和confirm()对话框的网络应用程序.
如何阻止Chrome显示此复选框?

我可以修改一个设置吗?
我知道我可以修改源代码,但我希望它能让Chrome仍然自动更新.
我不需要担心其他浏览器,因为该应用仅在Chrome中运行.
我有管理员访问运行该应用程序的(Windows)计算机.
sac*_*een 42
你不能.这是一个浏览器功能,可以防止网站显示数百个警报,以防止您离开.
但是,您可以查看模式弹出窗口,如jQuery UI Dialog.这些是显示自定义对话框的javascript警告框.它们不使用默认alert()功能,因此可以完全绕过您遇到的问题.
我发现,有很多的消息框和确认的应用程序有很多更好的用户体验,如果您使用自定义对话框而不是默认的提醒和确认.
Dea*_*ers 10
这就是我最终要做的事情,因为我们有一个不受我们控制的多个用户的网络应用程序......(@ DannyBeckett我知道这不是你问题的确切答案,而是那些正在关注的人你的问题可能会有所帮助.)你至少可以检测他们是否没有看到对话框.您最有可能想要更改的内容,如显示时间或实际显示的内容.请记住,这只会通知用户他们已经设法点击那个小复选框.
window.nativeAlert = window.alert;
window.alert = function (message) {
var timeBefore = new Date();
var confirmBool = nativeAlert(message);
var timeAfter = new Date();
if ((timeAfter - timeBefore) < 350) {
MySpecialDialog("You have alerts turned off");
}
}
window.nativeConfirm = window.confirm;
window.confirm = function (message) {
var timeBefore = new Date();
var confirmBool = nativeConfirm(message);
var timeAfter = new Date();
if ((timeAfter - timeBefore) < 350) {
MySpecialDialog("You have confirms turned off");
}
return confirmBool;
}
Run Code Online (Sandbox Code Playgroud)
显然我已将时间设置为3.5毫秒.但经过一些测试后,我们只能在大约5毫秒的时间内点击或关闭对话框.
我知道每个人都在道德上反对这一点,但我知道有理由开始实际的开玩笑.我认为Chrome通过在警报消息之间强制执行强制性的一秒间隔时间,对此采取了坚实的立场.这使访问者有足够的时间关闭页面或刷新,如果他们被困在烦人的恶作剧网站上.
所以要回答你的问题,这都是时间问题.如果您每秒多次提醒,Chrome会创建该复选框.这是一个变通方法的简单示例:
var countdown = 99;
function annoy(){
if(countdown>0){
alert(countdown+" bottles of beer on the wall, "+countdown+" bottles of beer! Take one down, pass it around, "+(countdown-1)+" bottles of beer on the wall!");
countdown--;
// Time must always be 1000 milliseconds, 999 or less causes the checkbox to appear
setTimeout(function(){
annoy();
}, 1000);
}
}
// Don't alert right away or Chrome will catch you
setTimeout(function(){
annoy();
}, 1000);
Run Code Online (Sandbox Code Playgroud)
小智 -27
function alertWithoutNotice(message){
setTimeout(function(){
alert(message);
}, 1000);
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
132453 次 |
| 最近记录: |