Tips on floating window _ javascript in the lower right corner supported by multiple browsers

Source: Internet
Author: User
Supports floating windows in the lower right corner of various browsers. For more information, see. The Code is as follows:


Script
Function $ (id)
{
Return document. getElementById (id );
}
Var LoginUI = !! Window. LoginUI || {};
LoginUI. getViewportWidth = function (){
Var width = 0;
If(document.doc umentElement & document.doc umentElement. clientWidth ){
Widthdomaindocument.doc umentElement. 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.doc umentElement. clientHeight ){
Height1_document.doc umentElement. clientHeight ;}
Else if (document. body & document. body. clientHeight ){
Height = document. body. clientHeight ;}
Return height;
}
LoginUI. getViewportScrollX = function (){
Var scrollX = 0;
If(document.documentelement&document.doc umentElement. scrollLeft ){
ScrollX=document.doc umentElement. 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.doc umentElement. scrollTop ){
Scrollypolicdocument.doc umentElement. 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, and below is a floating window

The Code is as follows:


Dfddfdf

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.