• 定时出现和消失的层


     <script type="text/javascript">
    <!--
            /*
            message:要显示的消息
            x,y:显示消息框的坐标,默认为左上角
            delay:延迟多长时间消失,-1为永不消失,单位为毫秒
            */
            function feedBackMessage(message, x, y, delay) {
                if (!message) return;
                //只允许百分数或数值参数
                x = /\d{1,2}%|100%|left|right/.test(x) ? x : (parseInt(x) || 0) + "px";
                y = /\d{1,2}%|100%|top|bottom/.test(y) ? y : (parseInt(y) || 0) + "px";
                delay = parseInt(delay) || -1;
                var fdDiv = document.getElementById('show_feedBack_message');
                if (!fdDiv) {
                    var showMessage = document.createElement("<div id='show_feedBack_message' style='z-index:10000;filter:alpha(opacity=100);position:absolute;white-space:nowrap'><img src='/images/loading22.gif'/></div>");
                    document.body.appendChild(showMessage);
                    fdDiv = document.getElementById('show_feedBack_message');
                }

                if (feedBackMessage.timer) { clearInterval(feedBackMessage.timer) }
                fdDiv.innerText = message;
                fdDiv.style.display = "";
                var docWidth = document.documentElement.scrollWidth > document.documentElement.clientWidth ? document.documentElement.scrollWidth : document.documentElement.clientWidth;
                var docHeight = document.documentElement.scrollHeight > document.documentElement.clientHeight ? document.documentElement.scrollHeight : document.documentElement.clientHeight;
                if (/left|right/.test(x)) {
                    x = (x == "left") ? "0px" : (docWidth - fdDiv.offsetWidth) + "px";
                }
                if (/top|bottom/.test(y)) {
                    y = (y == "top") ? "0px" : (docHeight - fdDiv.offsetHeight) + "px";
                }
                fdDiv.style.left = x;
                fdDiv.style.top = y;
                fdDiv.filters.Alpha.Opacity = 100;

                //渐隐效果
                var step = parseInt(delay / 100);
                var alpha = fdDiv.filters.Alpha.Opacity;
                if (delay != -1) {
                    feedBackMessage.timer = setInterval(function() {
                        if (fdDiv.filters.Alpha.Opacity > 0) {
                            fdDiv.filters.Alpha.Opacity--
                        } else {
                            clearInterval(feedBackMessage.timer);
                            fdDiv.style.display = "none"
                        }
                    }, step);
                }
            }
    //-->
    </script>

  • 相关阅读:
    react使用react-hot-loader实现局部热更新
    React的环境搭建以及脚手架的安装
    Git常用命令及方法大全
    centos7.6
    Spring Boot 如何提升服务吞吐量?
    RabbitMQ 的核心概念,看了必懂!
    Jenkins 自动化部署 Java 项目,厉害~
    Spring Boot 太狠了,一口气发布了 3 个版本!
    牛逼哄哄的 RabbitMQ 到底有啥用?
    为什么 HTTPS 是安全的?图文详解!
  • 原文地址:https://www.cnblogs.com/tangself/p/1817075.html
Copyright © 2020-2023  润新知