首页 >web前端 >js教程 >多浏览器支持的右下角浮动窗口_javascript技巧

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

WBOY
WBOY原创
2016-05-16 18:30:50956浏览
复制代码 代码如下:

<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

声明:
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn