JS scroll Code following the scroll bar

Source: Internet
Author: User

CopyCode Code: var STR = "Customer Service ";
VaR objft = new floatt ("floatmenu1", STR, 942,137,125,200 );
Objft. floatrun ();

// JS scroll with the scroll bar
// Pobjname: HTML element ID
// Ptext: HTML Element Content
// Others
Function floatt (pobjname, ptext, pstmnleft, pstmngap1, pstmngap2, pstmnbase, pstmnactivatespeed, pstmnscrollspeed)
VaR floatmenu;
VaR stmnleft = pstmnleft;
VaR stmngap1 = pstmngap1;
VaR stmngap2 = pstmngap2;
VaR stmnbase = pstmnbase;
VaR stmnactivatespeed = pstmnactivatespeed;
VaR stmnscrollspeed = pstmnscrollspeed;

This. floatrun = function (pobjname)
VaR newdiv = Document. createelement ("Div ");
Newdiv. ID = pobjname;
Newdiv. innerhtml = ptext;
Newdiv. style. Position = "absolute ";
Document. Body. appendchild (newdiv );
Floatmenu = Document. getelementbyid (pobjname );
Floatmenu. style. Display = "";
Floatmenu. style. Top = document.doc umentelement. scrolltop + stmnbase + "PX ";

Floatmenu. style. Left = stmnleft + "PX ";
Refreshstaticmenu ();

Refreshstaticmenu = function ()
VaR stmnstartpoint, stmnendpoint, stmnrefreshtimer;

Stmnstartpoint = parseint (floatmenu. style. Top, 10 );
Stmnendpoint = document.doc umentelement. scrolltop + stmngap2;
If (stmnendpoint <stmngap1) stmnendpoint = stmngap1;

If (stmnstartpoint! = Stmnendpoint)
{< br> stmnscrollamount = math. ceil (math. ABS (stmnendpoint-stmnstartpoint)/15);
floatmenu. style. top = parseint (floatmenu. style. top, 10) + (stmnendpoint stmnrefreshtimer = stmnscrollspeed;
}< br> else
{< br> stmnrefreshtimer = stmnactivatespeed;
}< br> setTimeout ("refreshstaticmenu ();", stmnrefreshtimer);
}< BR >}

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.