/***
* 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 弹窗的使用的更多相关文章

  1. 一个简单的页面弹窗插件 jquery.pageMsgFrame.js

    页面弹窗是网站中常用的交互效果,它可以强提示网站的某些信息给用户,或者作用于某些信息的修改等等功能. 这几天在做一个项目的时候,就顺捎把这个插件写一下,栽棵树,自己乘凉吧. 原创博文,转载请注明出处: ...

  2. cefsharp重写默认js弹窗(alert/confirm/prompt)

    1.设置js弹窗控制器 webView.JsDialogHandler = this;  //js弹窗控制 this表示本类对象,所以本类要实现IJsDialogHandler接口 2.实现IJsDi ...

  3. jQuery.validationEngine.js学习

    项目中使用到了这个插件,抽了个空,看了一下. (function($){ var method ={} $.fn.validationEngine = function(){} $.validatio ...

  4. jquery 、 JS 脚本参数的认识与使用

    jquery . JS 脚本参数的认识与使用 如何使用jquery刷新当前页面 下面介绍全页面刷新方法:有时候可能会用到 window.location.reload(); //刷新当前页面. par ...

  5. jQuery实现广告弹窗

    首先设置一个固定的窗口位于右下角,效果如下: 代码: jQuery实现广告弹窗.html 之后将该窗口初始设为隐藏,通过代码实现3秒自动显示,5秒自动隐藏,其效果如下: <!DOCTYPE ht ...

  6. jQuery的dialog弹窗实现

    jQuery实现dialog弹窗: html代码如下: <input type="button" onclick="performances();" va ...

  7. 图片上传(方法一:jquery.upload.js)

    一.在JSP页面引入jquery.upload.js 文件: <script type="text/javascript" src="${ctx}/script/j ...

  8. 利用jquery.touchSwipe.js实现的移动滑屏效果。

    利用jquery.touchSwipe.js实现的移动滑屏效果. 亲测:兼容ie8及各种浏览器 <script type="text/javascript" src=&quo ...

  9. jquery.cookie广告弹窗点击关闭后一天弹一次

    jquery.cookie广告弹窗点击关闭后一天弹一次 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN&qu ...

随机推荐

  1. iOS之内购

    很久之前就想出一篇IOS内付费的教程,但是一查网上的教程实在太多了,有的写得真的蛮不错的,就心想算了,于是就保存在草稿箱了.至于为什么写完它呢!真是说来话长,最近公司有个项目经理跑来问我有关苹果内付费 ...

  2. git merge branches

    git clone url #克隆新的版本库 git init git pull repo_name #有关联的远程库,抽取并和本地合并 git fetch remote_repo_name #抽取并 ...

  3. poj 3254 状态压缩DP

    思路:把每行的数当做是一个二进制串,0不变,1变或不变,找出所有的合法二进制形式表示的整数,即相邻不同为1,那么第i-1行与第i行的状态转移方程为dp[i][j]+=dp[i-1][k]: 这个方程得 ...

  4. python方式实现scoket通信

    要想明白这个网络通信还真的是离不开实现它实现流程图,看明白了大体很多都知道,觉得这个博主画的不错,地址是 http://www.cnblogs.com/wangcq/p/3520400.html 1. ...

  5. iOS下使用sqlite3

    1.创建数据库 使用firefox的sqlite manager创建和打开数据库,详细请参考: http://www.cnblogs.com/hanjun/archive/2012/10/29/274 ...

  6. office2013 win 32bit (含激活工具)

    office2013官方下载免费完整版32位(含永久激活工具) 百度云盘:http://pan.baidu.com/s/1jHgfZ1s

  7. Jackson - Features for configuring Java-to-JSON mapping

    Following on/off features are defined in SerializationConfig.Feature (for Jackson 1.x), or Serializa ...

  8. 面试之SQL(1)--选出选课数量>=2的学号

    ID      Course 1 AA 1 BB 2 AA 2 BB 2 CC 3 AA 3 BB 3 CC 3 DD 4 AA NULL NULL 选出选课数量>=2的学号 selectdis ...

  9. IIS实现301重定向

    301永久重定向对SEO无任何不好的影响,而且网页A的关键词排名和PR级别都会传达给网页B,网站更换了域名,表示本网页永久性转移到另一个地址,对于搜索引擎优化|SEO来说,给搜索引擎一个友好的信息,告 ...

  10. 随笔之Android平台上的进程调度探讨

    http://blog.csdn.net/innost/article/details/6940136 随笔之Android平台上的进程调度探讨 一由来 最近在翻阅MediaProvider的时候,突 ...