博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
原创,自己做的一个简单实用的提示小插件,兼容性很好,基本上都兼容!
阅读量:7025 次
发布时间:2019-06-28

本文共 3621 字,大约阅读时间需要 12 分钟。

实现的效果图如下:

 

jquery.message.box.js 插件代码如下:

/*     message    提示信息         url    跳转的url,有3个值可以选({1:指定跳转url地址,2:返回前一个页面,3:不跳转})       delay    提示的时间值        type    提示的类型,有3个值可以选({1:左侧提示类型,2:向下提示类型,3:居中提示类型})optionExtend    保留用户扩展的一个option(主要用来扩展您自己想要的message提示框的css效果) */$.fn.messagebox = function (message, url, delay, type, optionExtend) {    var options = {        style_msgprint: "",        style_tipsyinner: "",        style_tipsyarrow: "",        style: ""    }    var returnurl = '', messagebox_timer, obj_msgprint = '';    //obj_msgprint = "msgprint_";    obj_msgprint = "msgprint_" + parseInt(Math.random() * 1000);    optionExtend = $.extend({}, options, optionExtend || {});//继承合并,形成组合的options参数    clearTimeout(messagebox_timer);//清除定时器    //$("#" + obj_msgprint).remove();    var m_body = $(this);    delay = (typeof delay == "undefined" ? 5000 : delay);//提示时间值    returnurl = url;//返回的Url    var str;    //位于文本框,左侧提示类型    if (type == 1) {        optionExtend.style_msgprint = "float:left;margin:0px;padding:0px 10px;display:inline-block";        optionExtend.style_tipsyarrow = "width:0px;";    } //位于文本框,向下提示类型     else if (type == 2) {                optionExtend.style_msgprint = "padding:0px";        optionExtend.style_tipsyarrow = "width:18px;top:-6px";    }    str = '
' + message + '
'; m_body.append(str); //居中提示类型 if (type == 3) { var dom_obj = document.getElementById(obj_msgprint); var ext_width = $("#" + obj_msgprint).attr("style", optionExtend.style); dom_obj.style.top = (document.documentElement.scrollTop + (document.documentElement.clientHeight - $("#" + obj_msgprint).height()) / 2) + "px"; dom_obj.style.left = (document.documentElement.scrollLeft + (document.documentElement.clientWidth - $("#" + obj_msgprint).width()) / 2) + "px"; } $("#" + obj_msgprint).fadeIn(1000, function () { messagebox_timer = setTimeout(messagebox_out, delay) }); function messagebox_out() { if (returnurl == undefined || returnurl == '') { $("#" + obj_msgprint).fadeOut(1000, function () { $(this).remove(); }); } if (returnurl == "back") { this.history.back(-1) } else if (returnurl != "" && returnurl != undefined) { this.location.href = returnurl } }};

tipsy.css 样式代码如下:

.tipsy { padding-top: 9px; font-size: 14px; position: absolute; margin-top: 10px; z-index: 100000; }.tipsy-inner { background-color: #333; color: white; text-align: center;box-shadow: 0 0 4px 0 rgba(0, 0, 0, 0.2);}.tipsy-inner { border-radius: 5px; -moz-border-radius:5px; -webkit-border-radius:5px; }.tipsy-arrow { position: absolute; background: url('./images/archivePopUp-tip.png') no-repeat top center;}.tipsy-inner1 { padding: 10px; background-color: #838383; color: white;text-align: center;     box-shadow: 0 0 4px 0 rgba(0, 0, 0, 0.2);}.tipsy-inner1 { border-radius: 5px; -moz-border-radius:5px; -webkit-border-radius:5px; }.tipsy-arrow1 { position: absolute; background: url('./images/archivePopUp-tip1.png') no-repeat top center; height: 17px; }.tipsy-n .tipsy-arrow1 { top: 0; left: 46%;}

html代码调用如下:

    提示 jquery.message.box Demo            

 

 

 

转载于:https://www.cnblogs.com/Kummy/archive/2013/05/02/3054274.html

你可能感兴趣的文章
前端UI框架小汇总
查看>>
ecshop 批量生成订单信息
查看>>
Java常用系统变量收集
查看>>
基于Hadoop2.7.3集群数据仓库Hive1.2.2的部署及使用
查看>>
常见负载均衡的优点和缺点对比(Nginx、HAProxy、LVS)
查看>>
Mac电脑C语言开发的入门帖
查看>>
C++ 中 int、 char、 char*、 const char*、 string之间的转换
查看>>
上班两周
查看>>
洛谷P4242 树上的毒瘤
查看>>
导数和微分
查看>>
JQ实现树形菜单点击高亮
查看>>
函数动态参数
查看>>
const 与readonly的异同
查看>>
hostapd修改beacon帧和probe response帧
查看>>
ASP.NET-FineUI开发实践-4
查看>>
华为机试题 -- 明明的随机数
查看>>
mysql分区方案的研究
查看>>
python 24day--python面向对象编程
查看>>
前后端文件上传
查看>>
python中使用openpyxl模块时报错: File is not a zip file
查看>>