javascript confirm box causing idleTimeout jquery plugin to show dialog at wrong time
I've been using the idleTimeout jquery plugin from erichynds.com and it has been working fine in Firefox and IE...however I uncovered a weird problem when using this in chrome 11.0 .
Im using javascript "confirm" alerts to help handle the delete of items. In Chrome, anytime the "confirm" box is called the "idleTimeout" dialog box shows up, as if the user was idle and the mouse not moving....this occurs immediately after I press one of the buttons on the confirm prompt.
I tried using the jquery ui dialog box instead of the javascript "confirm" box and the problem went away, howev开发者_运维技巧er, I have to use a "synchronous" confirm box because of the requirements I have, so I had to scrap the jquery ui dialog box.
Any ideas how to get around this problem? Thanks in advance.
Found the solution at this link, down about half the way another user posted this fix for anyone else who comes across this.
link
No idea why Chrome alert/confirm causes idle to be triggered, but here is my work-around. In jquery.idletimer.js, the toggleSTate function, replace the the "// reset timeout counter" with:
// reset timeout counter
var elapsed = (+new Date) - f.olddate;
f.olddate = +new Date;
// handle Chrome always triggering idle after js alert or comfirm popup
if (idle && (elapsed < timeout)) {
idle = false;
clearTimeout($.idleTimer.tId);
if (enabled)
$.idleTimer.tId = setTimeout(toggleIdleState, timeout);
return;
}
精彩评论