开发者

How to Delay automatic opening of Modal Dialog box window in JQuery 1.5.x?

The following dialog box works nicely when clicked upon:

<a href="#" onclick="jQuery('#dialogX').dialog('open');
             return false"><? echo __("Under Construction")?></a>

The javascript sitting at the bottom of the html triggers the action:

jQuery("#dialogX").dialog({bgiframe: true, autoOpen:开发者_运维技巧 false, modal: true});

Now, what I would wish, is to have the dialog popup after say 2 seconds (insterad of immediately). I saw the option autoOpen and when setting the value to 2000 instead of false, that helas dit not work: it opens immediately. What am I missing?

Thanks very much for your hints and wish you a nice weekend.


You can use

var timeoutID = window.setTimeout(func, delay, [param1, param2, ...]);
var timeoutID = window.setTimeout(code, delay);

from https://developer.mozilla.org/en/DOM/window.setTimeout It executes a code snippet or a function after specified delay.

So

setTimeout(function(){ showDialog() }, 2000);

should solve your problem.

Also have a look at the .delay( n ) method. http://api.jquery.com/delay/

$('.notice').fadeIn().delay(2000).fadeOut('slow'); 
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜