function z_alert(msg){
    //创建提示框盒子,设置盒子的css样式
    var msgBox=document.createElement("div");
    msgBox.style.width="300px";
    msgBox.style.borderRadius="5px";
    msgBox.style.position="fixed";
    msgBox.style.zIndex=100000;
    var maxleft=(window.innerWidth-400)/2;
    msgBox.style.top="100px";
    msgBox.style.left=maxleft+"px";

  //创建遮荫层,背景变暗
    var bg=document.createElement("div");
    bg.style.height=window.innerHeight+"px";
    bg.style.width=window.innerWidth+"px";
    bg.style.position="fixed";
    msgBox.style.zIndex=99999;
    bg.style.top="0px";
    bg.style.left="0px";
    bg.style.background="black";
    bg.style.opacity="0.2";

//创建标题
    var msgTitle=document.createElement("div");
    msgTitle.style.lineHeight="40px";
    msgTitle.style.borderTopLeftRadius="5px";
    msgTitle.style.borderTopRightRadius="5px";
  msgTitle.style.background="背景图片地址";
    msgTitle.style.color="#fff";
    msgTitle.style.fontSize="18px";

  //移动上去鼠标的样式
    msgTitle.style.cursor="move";
    msgTitle.style.textAlign="center";
    var span=document.createElement("span");
    span.innerText="提示";

//创建内容部分的盒子
    var content=document.createElement("div");
    content.style.height="100px";
    content.style.background="#fff";

//传入的提示信息参数
    content.innerText=msg;
    content.style.overflowY="auto";
    content.style.textAlign="center";
    content.style.verticalAlign="middle";
    content.style.padding="40px";
    
    //创建盒子底部
    var bottom=document.createElement("div");
    bottom.style.height="30px";
    bottom.style.background="#149BDF";
    bottom.style.padding="5px";
    bottom.style.borderBottomLeftRadius="5px";
    bottom.style.borderBottomRightRadius="5px";
    
    //创建关闭按钮
    var close=document.createElement("div");
    close.innerHTML="确定";
    close.style.cursor="pointer";
    close.style.width="65px";
    close.style.padding="3px 15px";
    close.style.background="#fff";
    close.style.borderRadius="3px";
    close.style.margin="0 auto";
    close.style.textAlign="center";
    close.onclick=function(){
        msgBox.style.visibility="hidden";
        bg.style.visibility="hidden";
    }
    
    //拼接各级元素
    msgBox.appendChild(msgTitle);
    msgTitle.appendChild(span);
    msgBox.appendChild(content);
    msgBox.appendChild(bottom);
    bottom.appendChild(close);
    document.body.appendChild(msgBox);
    document.body.appendChild(bg);
}

代码空间项目 -- alert窗口自定义的更多相关文章

  1. 代码空间项目 -- InstantiationException的异常

    java.lang.InstantiationException实例化异常.当试图通过newInstance()方法创建某个类的实例,而该类是一个抽象类或接口时,抛出该异常. 这次项目中查询type时 ...

  2. 代码空间项目 -- 获取当前时间之前的某一天-Calender类的使用

    Calendar类的静态方法getInstance()可以初始化一个日历对象:Calendar now = Calendar.getInstance(); 1.Calendar的基本用法calenda ...

  3. 代码空间项目 -- cookie的基本使用

    cookie在日常开发b/s架构时候经常使用,可以在记住用户,方便自动登录,也可以记住用户的偏好并对应推送广告 下面说说开发时候的基本用法: 1.创建cookie//设置cookie,键值对形式Coo ...

  4. c++实现输入法窗口自定义的代码

    #pragma once #include <Windows.h> #include <imm.h> #include <string> #pragma comme ...

  5. VS Code项目中共享自定义的代码片段方案

    VS Code项目中共享自定义的代码片段方案 一.问题背景 项目中注释风格不统一,如何统一注释风格 一些第三方组件库名称太长,每次使用都需要找文档,然后复制粘贴 部分组件库有自己的Snippets插件 ...

  6. 雷林鹏分享:jQuery EasyUI 窗口 - 自定义窗口工具栏

    jQuery EasyUI 窗口 - 自定义窗口工具栏 默认情况下,窗口(window)有四个工具:collapsible.minimizable.maximizable 和 closable.比如我 ...

  7. 超详细的Xcode代码格式化教程,可自定义样式。

    超详细的Xcode代码格式化教程,可自定义样式. 为什么要格式化代码 当团队内有多人开发的时候,每个人写的代码格式都有自己的喜好,也可能会忙着写代码而忽略了格式的问题.在之前,我们可能会写完代码后,再 ...

  8. jeecg项目子窗口获得父窗口元素id

    jeecg项目子窗口获得父窗口元素id, var parentWin = frameElement.api.opener;alert($(parentWin.document).find(" ...

  9. 雷林鹏分享:jQuery EasyUI 窗口 - 自定义带有工具条和按钮的对话框

    jQuery EasyUI 窗口 - 自定义带有工具条和按钮的对话框 您可以创建一个带有工具栏(toolbar)和按钮(button)的对话框(dialog),可以从 HTML 标记创建.这个教程描述 ...

随机推荐

  1. hdu 3189(网络流+二分枚举)

    Steady Cow Assignment Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 6422   Accepted: ...

  2. iOS11及Xcode9适配问题汇总

    UIScrollView and UITableView的新特性 ScrollView 如果有一些文本位于UI滚动视图的内部,并包含在导航控制器中,现在一般navigationContollers会传 ...

  3. 天梯赛 - L2-005 集合相似度

    题目链接:https://www.patest.cn/contests/gplt/L2-005 这个题理解是个大问题啊,“给定两个整数集合,它们的相似度定义为:Nc/Nt*100%.其中Nc是两个集合 ...

  4. TopCoder SRM 701 Div2 Problem 900 ThueMorseGame(博弈+预处理)

    题意  Alice和Bob在玩一个游戏,Alice先手. 每次一个人可以从一堆式子中拿走任意数量(不超过m)的式子. 取走最后一颗式子的人胜利. 当一个取完某一步的时候剩下的石子数量的二进制表示中1的 ...

  5. stun简介

    转载 http://blog.csdn.net/mazidao2008/article/details/4934257 STUN(Simple Traversal of UDP over NATs,N ...

  6. luogu P1040 加分二叉树

    题目描述 设一个n个节点的二叉树tree的中序遍历为(1,2,3,-,n),其中数字1,2,3,-,n为节点编号.每个节点都有一个分数(均为正整数),记第i个节点的分数为di,tree及它的每个子树都 ...

  7. 简单了解HTML5中的Web Notification桌面通知

    原文:http://www.zhangxinxu.com/wordpress/2016/07/know-html5-web-notification/ 需要注意的是,消息通知只有通过Web服务访问该页 ...

  8. 调用tensorflow中的concat方法时Expected int32, got list containing Tensors of type '_Message' instead.

    grid = tf.concat(0, [x_t_flat, y_t_flat, ones])#报错语句 grid = tf.concat( [x_t_flat, y_t_flat, ones],0) ...

  9. windows10系统下安装nginx的安装步骤

    打开nginx的官网:http://nginx.org/,下载最新的稳定版本.   下载完成后,解压到你想要解压的文件路径中,我解压到了D盘中,并把文件名改为nginx:进入文件内,打开nginx.e ...

  10. LattePanda 之深入学习 Firmata通讯

    前言 原创文章,转载引用务必注明链接,水平有限,如有疏漏,欢迎指正. 本文使用Markdown写成,为获得更好的阅读体验和正常的链接.图片显示,请访问我的博客原文: http://www.cnblog ...