<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>高さを返します。 <br>} <br>LoginUI.getViewportScrollX = function(){ <br>varscrollX=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>returnscrollX ; <br>} <br>LoginUI.getViewportScrollY=function() { <br>varscrollY=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>returnscrollY ; <br>} <br>functionscrollMsgTip() <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>関数scrollTip() <br>{ <br>scrollMsgTip() <br>} <br>window.onload = window.onscroll =scrollTip; <br></script>
上は js代码、下は浮動窗口