zoukankan      html  css  js  c++  java
  • js重写alert()弹窗

    //重写alert
    window.alert = function(str)
    {
    var alertFram = document.getElementById('alertFram');
    var shield = document.createElement("DIV");
    shield.id = "shield";
    shield.style.position = "absolute";
    shield.style.left = "50%";
    shield.style.top = "50%";
    shield.style.width = "300px";
    shield.style.height = "300px";
    shield.style.marginLeft = "-150px";
    shield.style.marginTop = "-150px";
    shield.style.zIndex = "25";
    if( !alertFram ) { //防止重复弹出两个弹窗,且不能关闭
    alertFram = document.createElement("DIV");
    alertFram.id = "alertFram";
    alertFram.style.position = "fixed";
    alertFram.style.width = "300px";
    alertFram.style.height = "200px";
    alertFram.style.left = "50%";
    alertFram.style.top = "0";
    alertFram.style.marginLeft = "-150px";
    alertFram.style.marginTop = "30px";
    alertFram.style.textAlign = "center";
    alertFram.style.lineHeight = "150px";
    alertFram.style.zIndex = "1100";
    document.body.appendChild(alertFram);
    document.body.appendChild(shield);
    }else{
    alertFram.style.display = "";
    shield.style.display = "";
    }
    strHtml = '<div class="alert_ul" style="list-style:none;margin:0px;padding:0px;100%;">';
    strHtml += '<p class="alert_title" style="background: #fff;letter-spacing: 2px;text-align: left;padding-left: 20px;line-height: 50px;font-size: 20px;border-top: 1px solid #91AFA5;border-left: 1px solid #91AFA5;border-right: 1px solid #91AFA5;border-top-left-radius: 3px;border-top-right-radius: 3px;">消息提示</p>';
    strHtml += '<p class="alert_content" style="background: #fff;text-align: left;height: auto;color: #999;line-height: 25px;font-size: 14px;letter-spacing: 2px;padding: 0 20px 25px;border-left: 1px solid #91AFA5;border-right: 1px solid #91AFA5;">'+str+'</p>';
    strHtml += '<p class="alert_btn_wrap" style="background: #fff;line-height: 25px;padding: 0 18px 18px;border-left: 1px solid #91AFA5;border-right: 1px solid #91AFA5;border-bottom: 1px solid #91AFA5;border-bottom-left-radius: 3px;border-bottom-right-radius: 3px;"><input type="button" value="确 定" onclick="doOk()" class="alert_btn" style="border: none;outline: none; -moz-appearance: none; -webkit-appearance: none;appearance:none;80px;height:40px;background:#44E7BA;border-radius: 3px;;cursor:pointer;color:#fff; -webkit-transition: background 0.2s;transition: background 0.2s;font-size: 16px;"/></p>';
    strHtml += '</div>';
    alertFram.innerHTML = strHtml;

    this.doOk = function(){
    alertFram.style.display = "none";
    shield.style.display = "none";
    }
    alertFram.focus();
    document.body.onselectstart = function(){return false;};
    }
  • 相关阅读:
    django form表单验证
    Django messages框架
    pymysql 操作数据库
    python数据类型详解及列表字典集合推导式详解
    深入flask中的request
    修改sqlarchemy源码使其支持jdbc连接mysql
    深入理解Python中协程的应用机制: 使用纯Python来实现一个操作系统吧!!
    svg坐标转换
    近几年总结
    frp中的json模块
  • 原文地址:https://www.cnblogs.com/baixuemin/p/6485203.html
Copyright © 2011-2022 走看看