zoukankan      html  css  js  c++  java
  • 显示一行省略文字的详细信息

     function hindenMsg(e) {
                document.getElementById("tipDiv").style.display = "none";
            }
    
            var offX = 2;
            var offY = 0;
            var width = 0;
            var height = 0;
            var scrollX = 0;
            var scrollY = 0;
            var x = 0;
            var y = 0;
            function conentall(msg) {
                var tip = parent.document.getElementById("tipDiv");
                tip.style.display = "inline";
                tip.innerHTML = "<div><div class='innertip'><p class='innertip'>" + msg + "</p></div></div>";
    
                if (window.innerWidth) width = window.innerWidth - 18;
                else if (document.documentElement && document.documentElement.clientWidth)
                    width = document.documentElement.clientWidth;
                else if (document.body && document.body.clientWidth)
                    width = document.body.clientWidth;
    
                if (window.innerHeight) height = window.innerHeight - 18;
                else if (document.documentElement && document.documentElement.clientHeight)
                    height = document.documentElement.clientHeight;
                else if (document.body && document.body.clientHeight)
                    height = document.body.clientHeight;
    
                if (typeof window.pageXOffset == "number") scrollX = window.pageXOffset;
                else if (document.documentElement && document.documentElement.scrollLeft)
                    scrollX = document.documentElement.scrollLeft;
                else if (document.body && document.body.scrollLeft)
                    scrollX = document.body.scrollLeft;
                else if (window.scrollX) scrollX = window.scrollX;
    
                if (typeof window.pageYOffset == "number") scrollY = window.pageYOffset;
                else if (document.documentElement && document.documentElement.scrollTop)
                    scrollY = document.documentElement.scrollTop;
                else if (document.body && document.body.scrollTop)
                    scrollY = document.body.scrollTop;
                else if (window.scrollY) scrollY = window.scrollY;
    
                x = event.pageX ? event.pageX : event.clientX + scrollX;
                y = event.pageY ? event.pageY : event.clientY + scrollY;
    
                if (x + tip.offsetWidth + offX > width + scrollX) {
                    x = x - tip.offsetWidth - offX;
                    if (x < 0) x = 0;
                } else x = x + offX;
                if (y + tip.offsetHeight + offY > height + scrollY) {
                    y = y - tip.offsetHeight - offY;
                    if (y < scrollY) y = height + scrollY - tip.offsetHeight;
                } else y = y + offY;
                tip.style.left = x + "px";
                tip.style.top = y + "px";
            }
    <div id="tipDiv" style="border-right: #333366 1px solid; border-top: #333366 1px solid;
                display: none; z-index: 1; border-left: #333366 1px solid; border-bottom: #333366 1px solid;
                position: absolute;background-color: #ffffcc;">
            </div>
    
  • 相关阅读:
    js高程之作用域
    js继承的实现(原型/链、函数伪装)
    tween.js的API实践
    JavaScript高程第三版笔记(1-5章)
    flex布局使用方法简要汇总
    three.js中物体旋转实践之房门的打开与关闭
    遇见贵人的科学方法(通向财富自由学习笔记七)
    "活在未来" VS “活在当下”(通向财富自由学习笔记六)
    记CBS一次动人心魄的数据保卫战
    你的人生最重的枷锁是什么?(通向财富自由学习笔记五)
  • 原文地址:https://www.cnblogs.com/yunfeiqi/p/3419691.html
Copyright © 2011-2022 走看看