zoukankan      html  css  js  c++  java
  • 改造系统alert

    /*************************************************************************
     * 改造系统alert
     * param  str  传入要弹出的str
     *          pos  弹出的位置        1
     *                            2
     *                            3
     * return false
     *************************************************************************/
    window.alert = function (str, pos) {
        if (document.getElementById("tAlert") || !str) {
            return false;
        }
        var position = '';
        var pos = pos || 1;
        var tAlert_wrap = document.createElement("div");
        tAlert_wrap.setAttribute("id", "tAlert");
        tAlert_wrap.style.textAlign = "center";
        tAlert_wrap.style.position = "fixed";
        tAlert_wrap.style.zIndex = "100";
        switch (pos) {
            case 1:
                position = '10%';
                break;
            case 2:
                position = '40%';
                break;
            case 3:
                position = "65%";
                break;
            default:
                position = "10%";
                break;
        }
        tAlert_wrap.style.top = position;
        tAlert_wrap.style.width = "100%";
        document.getElementsByTagName("body")[0].appendChild(tAlert_wrap);
        var tAlert_in = document.createElement("div");
        tAlert_in.style.padding = "0.125rem 0.4375rem";
        tAlert_in.style.maxWidth = "6.25rem";
        tAlert_in.style.zIndex = "99";
        tAlert_in.style.fontSize = "0.375rem";
        tAlert_in.style.textShadow = "none";
        tAlert_in.style.display = "inline-block";
        tAlert_in.style.lineHeight = "0.5rem";
        tAlert_in.style.backgroundColor = "#000000";
        tAlert_in.style.color = "#ffffff";
        tAlert_in.style.borderRadius = "0.1875rem";
        tAlert_in.style.opacity = "0.8";
        tAlert_in.style.wordBreak = "break-all";
        tAlert_in.textContent = str;
        document.getElementById("tAlert").appendChild(tAlert_in);
        setTimeout(function () {
            document.getElementsByTagName("body")[0].removeChild(tAlert_wrap);
        }, 2000);
        return false;
    }
    

    牛了个逼,改造后,弹出会更美丽。弹出会自动关闭。弹出的位置可以自动调整。

  • 相关阅读:
    LF 第三章 装饰器和迭代器相关
    Python 文件管理
    Python 强制类型转换
    安装模块
    LF 第三章
    pep8 Python编码规则
    Help on module pyclbr:
    Help on class timedelta in module datetime:
    Help on function meshgrid in module numpy.lib.function_base:
    Help on module matplotlib.cm in matplotlib:
  • 原文地址:https://www.cnblogs.com/jiqing9006/p/8941272.html
Copyright © 2011-2022 走看看