显示一行省略文字的详细信息

 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>
原文地址:https://www.cnblogs.com/yunfeiqi/p/3419691.html