我有一个用户定义的函数,我想延迟它的执行。想延迟花式(),我正在使用 setTimeout。但它立即运行。我也设置了不同的时间延迟,但没有效果。还有其他方法还是我用错了??请帮忙。
提前致谢。阿里
$('a.vid').click(function(){
setTimeout(fancy(this) ,2000 );
});
function fancy(that){
var videoFile = $(that).attr('videofile');
var videoWidth = Number($(that).attr('videowidth'));
var videoHeight =Number( $(that).attr('videoheight'));
var videoCode = '<video width="'+videoWidth+'" height="'+videoHeight+'" controls autoplay autobuffer><source src="includes/video/'+videoFile+'.ogv" type="video/ogg" /><source src="includes/video/'+videoFile+'.mp4" type="video/mp4" /><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" width="'+videoWidth+'" height="'+(videoHeight+40)+'" id="lynda_video_player" align="middle"><param name="allowScriptAccess" value="sameDomain"><param name="allowFullScreen" value="true"><param name="movie" value="lynda_video_player.swf?videoFile=includes/video/'+videoFile+'.mp4&skinFile=lynda_video_skin.swf&videoFileWidth='+videoWidth+'&videoFileHeight='+videoHeight+'"><param name="quality" value="high"><param name="wmode" value="transparent"><param name="scale" value="noscale"><param name="salign" value="lt"><embed src="lynda_video_player.swf?videoFile=includes/video/'+videoFile+'.mp4&skinFile=lynda_video_skin.swf&videoFileWidth='+videoWidth+'&videoFileHeight='+videoHeight+'" quality="high" width="'+videoWidth+'" height="'+(videoHeight+40)+'" name="lynda_video_player" align="middle" allowscriptaccess="sameDomain" type="application/x-shockwave-flash" scale="noscale" salign="lt" wmode="transparent" allowfullscreen="true" pluginspage="http://www.macromedia.com/go/getflashplayer"></embed></object></video>';
$('#videoPlayer').html(videoCode);
$.fancybox({
'transitionIn' : 'fade',
'transitionOut' : 'fade',
'overlayColor' : '#000',
'overlayOpacity' : '.6',
'href' : '#videoPlayer'
});
}