Home > Web Front-end > JS Tutorial > Floating window in the lower right corner supported by multiple browsers_javascript skills

Floating window in the lower right corner supported by multiple browsers_javascript skills

WBOY
Release: 2016-05-16 18:30:50
Original
949 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