Home > Web Front-end > JS Tutorial > body text

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

WBOY
Release: 2016-05-16 18:30:50
Original
895 people have browsed it
复制代码 代码如下:

<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

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!