Copy Code code as follows:
<script>
function $ (ID)
{
return document.getElementById (ID);
}
var Loginui =!! Window. Loginui | | {};
Loginui.getviewportwidth = function () {
var width=0;
if (document.documentelement && document.documentElement.clientWidth) {
Width=document.documentelement.clientwidth;}
else if (document.body && document.body.clientWidth) {
Width=document.body.clientwidth;}
else if (window.innerwidth) {
width=window.innerwidth-18;}
return width;
}
Loginui.getviewportheight = function () {
var height=0;
if (window.innerheight) {
height=window.innerheight-18;}
else if (document.documentelement&&document.documentelement.clientheight) {
Height=document.documentelement.clientheight;}
else if (document.body&&document.body.clientheight) {
Height=document.body.clientheight;}
return height;
}
LOGINUI.GETVIEWPORTSCROLLX = function () {
var scrollx=0;
if (document.documentelement&&document.documentelement.scrollleft) {
Scrollx=document.documentelement.scrollleft;}
else if (document.body&&document.body.scrollleft) {
Scrollx=document.body.scrollleft;}
else if (Window.pagexoffset) {
Scrollx=window.pagexoffset;}
else if (WINDOW.SCROLLX) {
SCROLLX=WINDOW.SCROLLX;}
return SCROLLX;
}
Loginui.getviewportscrolly=function () {
var scrolly=0;
if (document.documentelement&&document.documentelement.scrolltop) {
Scrolly=document.documentelement.scrolltop;}
else if (document.body&&document.body.scrolltop) {
Scrolly=document.body.scrolltop;}
else if (Window.pageyoffset) {
Scrolly=window.pageyoffset;}
else if (window.scrolly) {
scrolly=window.scrolly;}
return scrolly;
}
function Scrollmsgtip ()
{
var t = loginui.getviewportheight () + loginui.getviewportscrolly ()-$ ("Msgtip"). offsetheight;
$ ("Msgtip"). Style.top = t + "px";
$ ("Msgtip"). Style.left = Loginui.getviewportwidth () + LOGINUI.GETVIEWPORTSCROLLX ()-$ ("Msgtip"). offsetwidth + "px";
}
function Scrolltip ()
{
Scrollmsgtip ()
}
window.onload = Window.onscroll = Scrolltip;
</script>
The above is the JS code, the following is a floating window
Copy Code code as follows:
<div style= ' position:absolute;top:0;left:0;width:300px;height:180px;border:3px double #AAA ' id= ' Msgtip ' > Dfddfdf</div>