Heim >Web-Frontend >js-Tutorial >多浏览器支持的右下角浮动窗口_javascript技巧

多浏览器支持的右下角浮动窗口_javascript技巧

WBOY
WBOYOriginal
2016-05-16 18:30:50955Durchsuche
复制代码 代码如下:

<script> <BR>function $(id) <BR>{ <BR>return document.getElementById(id); <BR>} <BR>var LoginUI = !!window.LoginUI || {}; <BR>LoginUI.getViewportWidth = function(){ <BR>var width=0; <BR>if(document.documentElement && document.documentElement.clientWidth){ <BR>width=document.documentElement.clientWidth;} <BR>else if(document.body && document.body.clientWidth){ <BR>width=document.body.clientWidth;} <BR>else if(window.innerWidth){ <BR>width=window.innerWidth-18;} <BR>return width; <BR>} <BR>LoginUI.getViewportHeight = function() { <BR>var height=0; <BR>if(window.innerHeight){ <BR>height=window.innerHeight-18;} <BR>else if(document.documentElement&&document.documentElement.clientHeight){ <BR>height=document.documentElement.clientHeight;} <BR>else if(document.body&&document.body.clientHeight){ <BR>height=document.body.clientHeight;} <BR>return height; <BR>} <BR>LoginUI.getViewportScrollX = function(){ <BR>var scrollX=0; <BR>if(document.documentElement&&document.documentElement.scrollLeft){ <BR>scrollX=document.documentElement.scrollLeft;} <BR>else if(document.body&&document.body.scrollLeft){ <BR>scrollX=document.body.scrollLeft;} <BR>else if(window.pageXOffset){ <BR>scrollX=window.pageXOffset;} <BR>else if(window.scrollX){ <BR>scrollX=window.scrollX;} <BR>return scrollX; <BR>} <BR>LoginUI.getViewportScrollY=function() { <BR>var scrollY=0; <BR>if(document.documentElement&&document.documentElement.scrollTop){ <BR>scrollY=document.documentElement.scrollTop;} <BR>else if(document.body&&document.body.scrollTop){ <BR>scrollY=document.body.scrollTop;} <BR>else if(window.pageYOffset){ <BR>scrollY=window.pageYOffset;} <BR>else if(window.scrollY){ <BR>scrollY=window.scrollY;} <BR>return scrollY; <BR>} <BR>function scrollMsgTip() <BR>{ <BR>var t = LoginUI.getViewportHeight() + LoginUI.getViewportScrollY() - $("msgtip").offsetHeight; <BR>$("msgtip").style.top = t + "px"; <BR>$("msgtip").style.left = LoginUI.getViewportWidth() + LoginUI.getViewportScrollX() - $("msgtip").offsetWidth + "px"; <BR>} <BR>function scrollTip() <BR>{ <BR>scrollMsgTip() <BR>} <BR>window.onload = window.onscroll = scrollTip; <BR></script>

以上是js代码,下面是浮动的窗口
复制代码 代码如下:

dfddfdf

Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn