jquery.prompt.js 弹窗的使用
/***
* Prompt提示语插件
* 编写时间:2013年4月8号
* version:Prompt.1.0.js
* author:小宇<i@windyland.com>
***/
(function($){
$.extend({
PromptBox:{
defaults : {
name : "T"+ new Date().getTime(),
content :"This is tips!", //弹出层的内容(text文本、容器ID名称、URL地址、Iframe的地址)
width : 200, //弹出层的宽度
height : 70,
time:2000,//设置自动关闭时间,设置为0表示不自动关闭
bg:true
},
timer:{
stc:null,
clear:function(){
if(this.st)clearTimeout(this.st);
if(this.stc)clearTimeout(this.stc);
}
},
config:function(def){
this.defaults = $.extend(this.defaults,def);
},
created:false,
create : function(op){
this.created=true;
var ops = $.extend({},this.defaults,op);
this.element = $("<div class='Prompt_floatBoxBg' id='fb"+ops.name+"'></div><div class='Prompt_floatBox' id='"+ops.name+"'><div class='content'></div></div>");
$("body").prepend(this.element);
this.blank = $("#fb"+ops.name); //遮罩层对象
this.content = $("#"+ops.name+" .content"); //弹出层内容对象
this.dialog = $("#"+ops.name+""); //弹出层对象
if ($.browser.msie && ($.browser.version == "6.0") && !$.support.style) {//判断IE6
this.blank.css({height:$(document).height(),width:$(document).width()});
}
},
show:function(op){
this.dialog.show();
var ops = $.extend({},this.defaults,op);
this.content.css({width:ops.width});
this.content.html(ops.content);
var Ds = {
width:this.content.outerWidth(true),
height:this.content.outerHeight(true)
};
if(ops.bg){
this.blank.show();
this.blank.animate({opacity:"0.5"},"normal");
}else{
this.blank.hide();
this.blank.css({opacity:"0"});
}
this.dialog.css({
width:Ds.width,
height:Ds.height,
left:(($(document).width())/2-(parseInt(Ds.width)/2)-5)+"px",
top:(($(window).height()-parseInt(Ds.height))/2+$(document).scrollTop())+"px"
});
if ($.isNumeric(ops.time)&&ops.time>0){//自动关闭
this.timer.clear();
this.timer.stc = setTimeout(function (){
var DB = $.PromptBox;
DB.close();
},ops.time);
}
},
close:function(){
var DB = $.PromptBox;
DB.blank.animate({opacity:"0.0"},
"normal",
function(){
DB.blank.hide();
DB.dialog.hide();
});
DB.timer.clear();
}
},
Prompt:function(con,t,ops){
if(!$.PromptBox.created){$.PromptBox.create(ops);}
if($.isPlainObject(con)){
if(con.close){
$.PromptBox.close();
}else{
$.PromptBox.config(con);
}
return true;
}
ops = $.extend({},$.PromptBox.defaults,ops,{time:t});
ops.content = con||ops.content;
$.PromptBox.show(ops);
}
})
})(jQuery);
Prompt插件
jquery.prompt.js是一款基于jQuery的插件,只要是设置弹出层的效果包括登陆等。
/*弹出层插件样式开始*/
.Prompt_floatBoxBg{display:none;width:100%;height:100%;background:#000;position:fixed !important;/*ie7 ff*/position:absolute;top:0;left:0;filter:alpha(opacity=0);opacity:0; z-index:999;}
.Prompt_floatBox{
z-index:1000;
display: block;
position: absolute;
padding:6px;
text-align:center;
top: 404.5px;
left: 531.5px;
height: auto;
z-index: 10000;
word-wrap: break-word;
-webkit-box-shadow: rgba(0, 0, 0, 0.498039) 0px 0px 15px;
box-shadow: rgba(0, 0, 0, 0.498039) 0px 0px 15px;
border-top-left-radius: 6px;
border-top-right-radius: 6px;
border-bottom-right-radius: 6px;
border-bottom-left-radius: 6px;
background-color: white;
opacity: 1;
}
.Prompt_floatBox .content{padding:10px;background:#fff;overflow-x:hidden;overflow-y: auto;}
/*弹出层插件样式结束*/
这个样式在js里面调用css
这个CSS主要是通过弹框插件的js直接给通过加class的方式加上样式
演示代码:记得这个插件式依赖jquery的需要引入jquery.min.js文件
<script src="js/jquery-1.8.3.min.js" type="text/javascript"></script>
<script type="text/javascript" src="js/jquery.prompt.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("a[pid]").click(function(){
var pid = $(this).attr("pid");
eval($("#"+pid).html());
});
});
</script>
</head>
<body>
<br />
<br />
<br />
<center>
<div class="prompt_tmp">
<a class="a" pid="tmp1">直接按默认打开</a><br/>
<pre class="brush: jscript;" id="tmp1">$.Prompt();</pre>
</div>
<div class="prompt_tmp">
<a class="a" pid="tmp2">设置提示内容</a><br/>
<pre class="brush: jscript;" id="tmp2">$.Prompt("欢迎光临本站!");</pre> //class="brush: jscript;"只是把代码语法高亮的显示出来,与pre搭配使用
</div>
<div class="prompt_tmp">
<a class="a" pid="tmp3">设置自动关闭时间为4s</a><br/>
<pre class="brush: jscript;" id="tmp3">$.Prompt("欢迎光临本站!4S",4000);</pre>
</div>
<div class="prompt_tmp">
<a class="a" pid="tmp4">设置自动关闭时间为100s,然后在2s后强制关闭</a><br/>
<pre class="brush: jscript;" id="tmp4">
$.Prompt("欢迎光临本站!2S",100000);
setTimeout(function(){
$.Prompt({close:true});
},2000);
</pre>
</div>
<div class="prompt_tmp">
<a class="a" pid="tmp5">修改默认参数后,不带参数打开</a><br/>
<pre class="brush: jscript;" id="tmp5">
var def = {
content:"欢迎来到jq-school!",
time:1000
}
$.Prompt(def);
$.Prompt();
</pre>
</div>
参考:jq-school.com/Detail.aspx?id=227
补充说明:当使用jQuery1.8.3以上版本时可能出现弹框弹不出来的问题
QQ:1689986723
jquery.prompt.js 弹窗的使用的更多相关文章
- 一个简单的页面弹窗插件 jquery.pageMsgFrame.js
页面弹窗是网站中常用的交互效果,它可以强提示网站的某些信息给用户,或者作用于某些信息的修改等等功能. 这几天在做一个项目的时候,就顺捎把这个插件写一下,栽棵树,自己乘凉吧. 原创博文,转载请注明出处: ...
- cefsharp重写默认js弹窗(alert/confirm/prompt)
1.设置js弹窗控制器 webView.JsDialogHandler = this; //js弹窗控制 this表示本类对象,所以本类要实现IJsDialogHandler接口 2.实现IJsDi ...
- jQuery.validationEngine.js学习
项目中使用到了这个插件,抽了个空,看了一下. (function($){ var method ={} $.fn.validationEngine = function(){} $.validatio ...
- jquery 、 JS 脚本参数的认识与使用
jquery . JS 脚本参数的认识与使用 如何使用jquery刷新当前页面 下面介绍全页面刷新方法:有时候可能会用到 window.location.reload(); //刷新当前页面. par ...
- jQuery实现广告弹窗
首先设置一个固定的窗口位于右下角,效果如下: 代码: jQuery实现广告弹窗.html 之后将该窗口初始设为隐藏,通过代码实现3秒自动显示,5秒自动隐藏,其效果如下: <!DOCTYPE ht ...
- jQuery的dialog弹窗实现
jQuery实现dialog弹窗: html代码如下: <input type="button" onclick="performances();" va ...
- 图片上传(方法一:jquery.upload.js)
一.在JSP页面引入jquery.upload.js 文件: <script type="text/javascript" src="${ctx}/script/j ...
- 利用jquery.touchSwipe.js实现的移动滑屏效果。
利用jquery.touchSwipe.js实现的移动滑屏效果. 亲测:兼容ie8及各种浏览器 <script type="text/javascript" src=&quo ...
- jquery.cookie广告弹窗点击关闭后一天弹一次
jquery.cookie广告弹窗点击关闭后一天弹一次 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN&qu ...
随机推荐
- Hessian详解
相比WebService,Hessian更简单.快捷.采用的是二进制RPC协议,因为采用的是二进制协议,所以它很适合于发送二进制数据.下面演示一个简单的Hessian示例程序.
- <Think Complexity> 用字典实现图
今天在图书馆闲逛的时候偶然看见<Think Complexity>(复杂性思考)这本书,下午看了一会儿觉得很有意思.本书第二章讲的是用Python实现的图,特别写篇博客记录. 首先,图 ...
- next_permutation()—遍历全排列
# next_permutation()--遍历全排列 template <class BidirectionalIterator> bool next_permutation (Bidi ...
- Windows Embedded CE 6.0开发环境的搭建
最近开始在学习嵌入式,在这里首先得安装Windows Embedded CE 6.0,其中遇到了很多问题,电脑的系统以及相关配置都会在安装过程中受到影响,因此笔者就安装中的问题以及环境搭建来介绍一下. ...
- 转:艾瑞咨询2016 IM云的发展趋势
转自: http://www.cnblogs.com/lingyunhu/p/rtc63.html
- Networking - Ethernet II 帧
Ethernet II 帧格式 DA SA Type Playload FCS DA(Destination Address): 该字段有 6 个字节,表示目的 MAC 地址. SA(Source A ...
- Android代码内存优化建议-OnTrimMemory优化
原文 http://androidperformance.com/2015/07/20/Android代码内存优化建议-OnTrimMemory优化/ OnTrimMemory 回调是 Androi ...
- 初学Android: 四大组件之Activity
1.activity (1)一个Activity通常就是一个单独的屏幕(窗口),简单来说activity就是一个交互界面,一般应用程序都要由一个或者多个activity组成. (2)Activity之 ...
- Agile.Net 组件式开发平台 - 服务器端部署
应用服务器: 操作系统要求推荐Windows Server 2008,服务器硬件如果支持64位建议安装64位操作系统产品以最大化发挥服务器性能. 安装操作系统Windows Server 2008,其 ...
- DOS批处理命令-CMD命令
CMD命令是重新开始一个命令解析器的实例.当然,他的功能并不止这么简单. Windows コマンド インタープリターの新しいインスタンスを開始します. 语法结构 CMD [/A | /U] [/Q] ...