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

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

WBOY
发布: 2016-05-16 18:30:50
原创
949 人浏览过
复制代码 代码如下:

<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

相关标签:
来源:php.cn
本站声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
最新问题
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板