Multi-browser supported floating window _javascript tips for the lower right corner

Source: Internet
Author: User
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>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.