<script type="text/javascript">
var filename = "PICC_V2.1.3.0_新增功能操作手册.doc";
window.onload = function(){
var dialog1;
dialog1 = new Dialog({width:310,height:250,title:"重要通知"});//background:pink;
dialog1.content.innerHTML ="<table ><tr style='margin-top: 5' style='height:4' >"+
"<td style='font-size:14px;'>通知:系统已于2014年04月16号升级到V2.1.3.0版本,相关新增功能手册如下:</td></tr><tr></tr><tr></tr>"+
"<tr><td><a href='#' style='font-size:13px;' onclick='setWinSize()'>1."+filename+"</a></td></tr></table>";
}
function setWinSize() {
window.location = "<%=request.getContextPath()%>/"+"filedown.do?filename="+filename;
}
</script>

需要引入以下js文件

  var Dialog = function(){
var options = arguments[0] || {};
this.title = options.title || "我只打",
this.width = options.width || 350,
this.height = options.height || 250,
this.container = document.createElement("div"),
this.id = "id" + Math.abs(new Date() * Math.random()).toFixed(0);
this.init();
}
Dialog.prototype = {
constructor: Dialog,
init: function() {
var me = this,container = me.container,width = me.width, height = me.height,
id = me.id,builder = [],t = "getElementsByTagName",
bg = function(pic){
var bgcolor = arguments[1] || 'transparent',
left = arguments[2] || 'left',
s = 'background:'+bgcolor + ' url(http://images.cnblogs.com/cnblogs_com/rubylouvre/205314/'
+ pic + ') no-repeat '+left+' center;';
return s;
};
if(typeof Dialog.z === "undefined"){
Dialog.zIndex = 999;
}
document.body.insertBefore(container,null);
container.id = id;
container.className = "popups";
builder.push('<div class="caption" >'+me.title+'</div>');
builder.push('<form><div class="replaceable"></div>');
builder.push('<div class="submitable">');
builder.push('<a class="negative" href="javascript:void(0)">取消</a>');
builder.push('<a class="positive" href="javascript:void(0)">确认</a>');
builder.push('</div></form>');
builder.push('<a class="closebtn" href="javascript:void(0)"></a>');
container.innerHTML = builder.join('');
var size = me.getBrowserWindowSize();
me.left = ((size.width - width)/2) >> 0;
me.top = ((size.height - height)/2) >> 0;
me.ie6 = /msie|MSIE 6/.test(navigator.userAgent); var divs = container[t]("div"),k = divs.length;
while (--k >= 0) {
if(divs[k].className == "replaceable"){
me.content = divs[k]
break;
}
} //设置样式
me.css(".popups","position:absolute;width:"+width+"px;height:"+
height+"px;right:"+14+"px;top:"+4+"px;"+"background:#ccc");//background:#68DFFB
container.style.zIndex = Dialog.zIndex++;
me.css(".popups .caption",'position:absolute;top:10px;left:10px;width:'+(width-50)+'px;height:20px;'+
'padding-left:30px;font:700 14px/20px "SimSun","Times New Roman";color: #fff;'+
bg("o_icon.gif","#68DFFB","5px"));
me.css(".popups .closebtn",'position:absolute;top:0;right:10px;display:block;width:28px; '+
'height:17px;text-decoration:none;'+ bg("o_dialog_closebtn.gif"));
me.css(".popups a.closebtn:hover",bg("o_dialog_closebtn_over.gif"));
me.css(".popups form","position:absolute;top:30px;left:10px;border:3px solid #68DFFB;width:"+(width-26)+"px;height:"+(height-51)+"px;background:#fff;");
me.css(".popups .submitable","position:absolute;bottom:0;border-top:1px solid #c0c0c0;width:100%;height:40px;background:#fff;");
var buttoncss = 'display:block;float:right;margin: 0.7em 0.5em;padding:2px 7px;border:1px solid #dedede;'
+ 'background:#f5f5f5;color:#a9ea00;font:700 12px/130% "SimSun","Times New Roman";text-decoration:none;';
me.css("a.positive",buttoncss);//IE6有bug,不能动态创建联合选择器
me.css("a.negative",buttoncss);
me.css("a.negative","color:#ff5e00;");
me.css("a.positive:hover","border:1px solid #E6EFC2;background:#E6EFC2;color:#529214;");
me.css("a.negative:hover","border:1px solid #fbe3e4;background:#fbe3e4;color:#d12f19;");
me.css("a.positive:active","border:1px solid #529214;background:#529214;color:#fff;");
me.css("a.negative:active","border:1px solid #d12f19;background:#d12f19;color:#fff;");
me.css("a","outline: 0;");
//按钮的圆角
var ff = /a/[-1]=='a';
if(ff){
me.css("a.positive","-moz-border-radius:4px;");
me.css("a.negative","-moz-border-radius:4px;");
}else{
me.css("a.positive","-webkit-border-radius:4px;");
me.css("a.negative","-webkit-border-radius:4px;");
}
//***************************
if (!+"\v1" ){
if(!document.namespaces.vml){
document.namespaces.add('vml', 'urn:schemas-microsoft-com:vml');
var vmlobj = document.createElement("<object classid=CLSID:10072CEC-8CC1-11D1-986E-00A0C955B42E id=VMLRender>"),
head = document.getElementsByTagName("head")[0];
head.appendChild(vmlobj);
document.createStyleSheet().addRule(".vml", "behavior: url(#VMLRender); display:inline-block;");
}
var rect = document.createElement('<vml:roundrect class="vml">');
container.insertBefore(rect,container.firstChild);
rect.style.cssText = "position:absolute;top:0px;left:0px;width:"+width+"px;height:"+height+"px;";
me.attr(rect,{arcsize:5 /Math.min(width, height),stroked:"f"});
rect.innerHTML = '<vml:fill class="vml" opacity="0.8" color="#68DFFB" />' +
'<vml:shadow class="vml" on="t" color="#333" opacity="0.2" offset="10px,10px" />'
}else{
var svg = me.createSVG("svg");
container.insertBefore(svg,container.firstChild);
me.attr(svg,{width:me.width+10+"px",height:me.height+10+"px"}); var defs = me.createSVG("defs");
svg.appendChild(defs); var filter = me.createSVG("filter");
defs.appendChild(filter);
me.attr(filter,{id:"filter"+id}); var feGaussianBlur = me.createSVG("feGaussianBlur");
filter.appendChild(feGaussianBlur)
me.attr(feGaussianBlur,{"in":"SourceAlpha",result:"blur-out",stdDeviation:1.5}); var feOffset = me.createSVG("feOffset");
filter.appendChild(feOffset)
me.attr(feOffset,{"in":"blur-out",result:"the-shadow",dx:0,dy:2}); var feBlend = me.createSVG("feBlend");
filter.appendChild(feBlend)
me.attr(feBlend,{"in":"SourceGraphic","in2":"the-shadow",mode:"normal"}); var shadow = me.createSVG("rect");
svg.appendChild(shadow);
me.attr(shadow,{x:"10px",y:"10px",width:me.width+"px",height:me.height+"px",rx:10,
fill:"#333",style:"opacity:0.2",filter:"url(#filter"+id+")"}); var rect = me.createSVG("rect");
svg.appendChild(rect);
me.attr(rect,{width:me.width+"px",height:me.height+"px",rx:5,fill:"#68DFFB",style:"opacity:0.8"});
}
//***************************IE6 弹出窗口中遮不住select******************************
if(me.ie6){
me.iframe = document.createElement("<iframe style='position:absolute;left:"+
me.left+"px;top:"+me.top+"px;width:"+(me.width+10)+"px;height:"+
(me.height+10)+"px;z-index:"+(Dialog.zIndex-2)+";filter:mask();display:none;' ></iframe>");
container.insertAdjacentElement('beforeBegin',me.iframe);
} //*****************************监听点击**************************
container.onclick = function(){
var ee = me.getEvent(), node = ee[1],tag = ee[2];
if(tag == "a" ){
switch(node.className){
case "closebtn" :
me.hide();
break;
case "positive" :
me.hide();
//form.submit();
break;
case "negative" :
break;
}
}
}
container.onmousedown = function(e){
e = e || window.event;
container.offset_x = e.clientX - container.offsetLeft;
container.offset_y = e.clientY - container.offsetTop;
document.onmousemove = function(e){
me.drag(e,me)
}
document.onmouseup = function(){
me.dragend(container)
}
}
},
drag:function(e,me){
e = e || window.event;//获得事件对象
var el = me.container;
var l = e.clientX - el.offset_x + "px",
t = e.clientY - el.offset_y + "px";
with(el.style){
left=l;
top=t;
cursor="move"
}
if(me.ie6){
with(me.iframe.style){
left=l;
top=t;
}
}
!+"\v1"? document.selection.empty() : window.getSelection().removeAllRanges();
},
dragend:function(el){
el.style.cursor = "";
document.onmouseup = document.onmousemove = null;
},
hide : function(){
this.container.style.display = "none" ;
if(this.ie6){
this.iframe.style.display = "none";
}
this.mode(0,0);
//下面两行目的是生成 html,body{width:auto;height:auto;overflow:auto;}
this.incss(document.body, {width:"auto",height:"auto",overflow:"auto"});
this.incss(document.documentElement, {width:"auto",height:"auto",overflow:"auto"});
},
show : function(){
this.container.style.display = "block" ;
if(this.ie6){
this.iframe.style.display = "block";
}
var size = this.getBrowserWindowSize();
this.mode(size.width, size.height);
}, getBrowserWindowSize :function(){
var de = document.documentElement;
return {
width: (de.clientWidth || document.body.clientWidth),
height:(de.clientHeight || document.body.clientHeight)
}
},
createSVG : function(tag){
return document.createElementNS("http://www.w3.org/2000/svg",tag);
},
attr: function(node,bag){
for(var i in bag){
if(bag.hasOwnProperty(i))
node.setAttribute(i,bag[i])
}
},
getEvent : function(e) {
e = e || window.event;
if (!e) {
var c = this.getEvent.caller;
while (c) {
e = c.arguments[0];
if (e && (Event == e.constructor || MouseEvent == e.constructor)) {
break;
}
c = c.caller;
}
}
var target = e.srcElement ? e.srcElement : e.target,
currentN = target.nodeName.toLowerCase(),
parentN = target.parentNode.nodeName.toLowerCase(),
grandN = target.parentNode.parentNode.nodeName.toLowerCase();
return [e,target,currentN,parentN,grandN];
},
mode:function(w,h){
var mask = Dialog.mask,me = this;
this.incss(document.body, {width:"100%",height:"100%",overflow:"hidden"});
this.incss(document.documentElement, {width:"100%",height:"100%",overflow:"hidden"});
this.incss(mask,{position:"absolute",background:"#fff",top:0,left:0,
width:w +"px",height:h +"px","-moz-user-select":"none"});
!+"\v1"? (mask.style.filter = "alpha(opacity=0)") : (mask.style.opacity = "0");
mask.onselectstart = function(e){
me.stopEvent(e);
}
mask.oncontextmenu = function(e){
me.stopEvent(e);
}
},
stopEvent:function(e){
e = e || window.event;
if(e.preventDefault) {
e.preventDefault();
e.stopPropagation();
}else{
e.returnValue = false;
e.cancelBubble = true;
}
},
incss:function(node,bag){
var str = ";"
for(var i in bag){
if(bag.hasOwnProperty(i))
str += i+":"+bag[i]+";"
}
node.style.cssText = str;
},
css:function(selector,declaration){
if(typeof document.createStyleSheet === 'undefined') {
document.createStyleSheet = (function() {
function createStyleSheet() {
var element = document.createElement('style');
element.type = 'text/css';
document.getElementsByTagName('head')[0].appendChild(element);
var sheet = document.styleSheets[document.styleSheets.length - 1];
if(typeof sheet.addRule === 'undefined')
sheet.addRule = function(selectorText, cssText, index) {
if(typeof index === 'undefined')
index = this.cssRules.length;
this.insertRule(selectorText + ' {' + cssText + '}', index);
};
return sheet;
}
return createStyleSheet;
})();
}
if(!!Dialog.sheet){
if(!Dialog.memory.exists(selector,declaration)){
Dialog.memory.set(selector,declaration);
Dialog.sheet.addRule(selector,declaration);
}
}else{
Dialog.sheet = document.createStyleSheet();
var memory = function(){
var keys = [],values = [],size = 0;
return {
get : function(k){
var results = [];
for(var i=0,l=keys.length;i<l;i++){
if(keys[i] == k){
results.push(values[i])
}
}
return results;
},
exists:function(k,v){
var vs = this.get(k);
for(var i=0,l=vs.length;i<l;i++){
if(vs[i] == v)
return true;
}
return false;
},
set : function(k,v){
keys.push(k);
values.push(v);
size++;
},
length :function(){
return size;
}
}
}
Dialog.memory = memory();
Dialog.memory.set(selector,declaration);
Dialog.sheet.addRule(selector,declaration);
Dialog.mask = document.createElement("div");
document.body.insertBefore(Dialog.mask,this.container);
}
}
}

漂亮提醒框js的更多相关文章

  1. iOS自学-监听按钮点击、提醒框

    //事件监听的问题 CGRect btn2Frame = CGRectMake(100.0, 150.0, 60.0, 44.0); //两种不同的方式创建 UIButton *btn2 = [UIB ...

  2. RovingUI组件库-包含堆栈式通知提醒框(Toast)的小程序组件库

    RovingUI是个人在开发小程序过程中将用到的组件集合而成的一个UI库,包含一些基本通用组件(按钮.栅格.通用样式.徽标.通知和面包屑). 源起得归于我在开发中没有找到现成的堆栈式提醒框(比如ant ...

  3. 巧妙使用 CSS3 的褪色和动画效果制作消息提醒框

    现代Web设计技术允许开发者快速实现大多数浏览器支持的动画.我想警告消息是很常见的,因为默认的JavaScript警告框的样式往往(与你自己设计的漂亮样式)很不协调很囧.这使开发者步入找出哪种解决方案 ...

  4. js搜索框 js仿百度搜索 js下拉框 jQuery.Autocomplete使用

    做了一个网站,需要根据文本框的输入模糊搜索数据库内容给出提示供用户选择,就找到了jQuery.Autocomplete 效果如下图: 该插件托管在github上,具体地址:https://github ...

  5. 常用UI模板,loading框,提醒框,弹框确认框

    css部分 #public_box{width:100%;height:100%;position:fixed;top:0;left:0;z-index:100;background:rgba(0,0 ...

  6. JS学习笔记(模态框JS传参)

    博主最近基于django框架的平台第一版差不多完成了 今天整理下开发过程中遇到的前端知识 基于前端bootstrap框架模态框传参问题 上前端html代码: <div class="m ...

  7. 左右选择框 js插件

    随着项目的进展,测试工程师在更多的浏览器中兼容性测试中,发现有些浏览器不支持option的触发事件,这就造成了先前一篇博文bootstrap 左右框多项选择示例 中左右选择框的失效,于是我就由原先的s ...

  8. LayUI中实现上级下拉框动态加载下级下拉框js

    js代码: var form = layui.form, layer = layui.layer; form.on("select(上级)", function(data){ va ...

  9. 很漂亮的SweetAlert.js 弹出层

    在线实例 实例演示 使用方法 swal("Here's a message!") 复制 参数详解 参数 默认值 描述 title null(required) 窗口的名称.可以通过 ...

随机推荐

  1. 性能测试工具LoadRunner17-LR之Controller windows系统资源性能常用计数器

    1.System %Total Processor Time 该计数值用于体现服务器整体的处理器利用率,对多处理器而言,该计数值体现的是所有CPU的平均利用率.如果该值的数值持续超过90%,则可以说明 ...

  2. Linux 安装 webmin

    下载webmin的rpm包 yum install webmin-rpm systemctl start webmin 即可

  3. Win7无法将图标(Chrome谷歌浏览器更新后无法锁定也适用)锁定到任务栏解决办法

    “将程序锁定到任务栏”是Windows 7中的一个非常有用的功能,它比之前的快速启动栏要来得简洁.但是我用了一段时间之后,发现“锁定到任务栏”这一个选项消失了,对图标点右键找不到这个图标,直接把图标拖 ...

  4. windows常用命令行总结

    cmd下的命令行 1.查看当前目录下的子目录 dir   或 dir /b 类似Linux 下的  ls 或者 ls -l 2.盘符切换  d: 3.进入目录 cd [目录名] 退一个目录 cd .. ...

  5. 前台异步传过来的URL中获取token/获取string链接中的token

    1.链接例子: string url = "http://domainName:port/1/2/3/4.htm?sysCode=1001020&token=QXJzemR3YXlW ...

  6. 如何使用JWT来实现单点登录功能

    我们平时自己开发项目,分布式的结构时,访问量不大,但是又不想搭建redis服务器,这时我觉得jwt不错. 个人理解,jwt就是类似于一把锁和钥匙,客户来租房(登录),我们需要给他进来(第一次登录)登记 ...

  7. 处理移动端自适应布局的方法- calc()与vw

    在处理移动端自适应布局时,目前前端最流行的方法应该就是使用媒体查询,来设置HTML的字体大小,然后用rem为单位对Dom的宽高进行设置,这个方法的优势在于兼容性方面很好,劣势则在于当前市场上不同的机型 ...

  8. C#队列Queue,利用队列处理订单

    一.什么是队列 队列(Queue)代表了一个先进先出的对象集合.当您需要对各项进行先进先出的访问时,则使用队列.当您在列表中添加一项,称为入队,当您从列表中移除一项时,称为出队. 这是摘抄网上的.做了 ...

  9. 自定义 sql Split函数 / 自定义mp_helptext查看存储

    1. 分割函数: --Split 表函数将一个字符串按指定分隔符进行分割,返回一个表. create function split( ),--待分割字符串 )--分割符 ))) as begin ) ...

  10. JavaScript 获取数组的最大值和最小值

    js获取数组最大值和最小值 使用apply方法: var a = [1,2,3,5]; console.log(Math.max.apply(null, a));//最大值 console.log(M ...