zoukankan      html  css  js  c++  java
  • 悬浮框的兼容性

    <!DOCTYPE html>
    <html lang="zh-cn">
    <head>
    <meta charset="utf-8" />
    <title>index</title>
    <meta name="author" content="" />
    <meta name="copyright" content="" />
    <!--[if lt IE 9]>
        <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
    <![endif]-->
    <style type="text/css">
    #wraper{width: 90%; height:600px; border:1px solid #789}
    #target{width:150px;height:150px;background: #f1f1f1}
    #container{width: 300px; height:300px; position:relative; top:0; left: 100px;background: #963}
    #outer{width:50px;height: 50px;background: #456789; position: relative; top: 50px;left: 50px}
    </style>
    </head>
    
    <body>
    <div id="wraper">
        <section id="target" class="">
            热点
        </section>
        <div id="container" style="display:none">隐藏的容器
            <div id="outer">事件离开了</div>
        </div>
    </div>
    <script type="text/javascript">
        
        var timer = null;
        function $(id) {
            return document.getElementById(id);
        }
    
        $("target").onmouseover = function(e) {
            clearTimeout(timer);
            $("container").style.display = "block";
        }
        $("target").onmouseout = function(e) {
            timer = setTimeout(function() {
                $("container").style.display = "none";
            }, 300)
        }
        $("container").onmouseover = function(e) {
            clearTimeout(timer);
        }
        /* *****
        * IE下,even对象有srcElement属性,但是没有target属性;Firefox下,even对象有target属性,但是没有srcElement属性
        * 解决方法:
        * var source = e.target || e.srcElement;
        * var target = e.relatedTarget || e.toElement;
        */
        $("container").onmouseout = function(e) {
            var e = e || window.event, target = e.relatedTarget || e.toElement;
            console.log("target: " + target);
            if (target != $("outer") && target != $("container")) {
                console.log('out container');
                $("container").style.display = "none";
            }
        }
    
    </script>
    </body>
    </html>
  • 相关阅读:
    华大MCU烧录流程
    使用 iperf 测试网络
    Linux的Flash测试【转】
    linux 系统 UDP 丢包问题分析思路 [转]
    [规划算法]Hybrid A *算法原理
    macos 硬盘无法正常识别
    oracle定时任务
    Redis 键(key)
    redis-benchmark性能测试
    redis安装
  • 原文地址:https://www.cnblogs.com/zhoulingfeng/p/3547720.html
Copyright © 2011-2022 走看看