ITeye博客

模拟alert对话框,N秒不点击自动关闭(基于jQuery模式对话框)

Hooopo · 2009-12-04 18:38 · jQuery · HTML · UI · jQuery · Rails · JavaScript · Markdown

jQuery 模式对话框地址:http://jqueryui.com/demos/dialog/ 代码: [code="js"] //jquery.alert.js (function($){ $.alert = function(message, timeToLive, options){ var ttl = timeToLive || 1000; var defaultOptions = $.extend({ title:window.location.host, height: 130, width: 385, modal: false },options || {}); if(!$("#jquery_alert").length){ $("body").append("

"); } $("#jquery_alert").dialog(defaultOptions); $("#jquery_alert").html(message); $("#jquery_alert").dialog("open"); setTimeout(function(){ $("#jquery_alert").dialog("close") },ttl); } })(jQuery); [/code] 以在rails使用为例: [code="rails"] <% content_for :head do %> <%= stylesheet_link_tag 'jquery' %> <%= stylesheet_link_tag 'jquery-ui/ui.all' %> <%= stylesheet_link_tag 'jquery-ui/ui.dialog' %> <%= javascript_include_tag 'jquery-ui/ui.dialog' %> <%= javascript_include_tag 'jquery.alert' %> <% end %> [/code] 默认样式: [img]http://t.douban.com/view/photo/photo/public/p355437424.jpg[/img] 经过我业余美工改过之后... [img]http://t.douban.com/view/photo/photo/public/p355437441.jpg[/img]

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。