Copy Code code as follows:
var str= "Customer service";
var objft=new floatt ("FloatMenu1", str,942,137,125,200,80,10);
Objft.floatrun ();
JS follows the scroll bar scroll floating
pobjname:html Element ID
ptext:html element content
Others see for themselves
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.documentElement.scrollTop + stmnbase+ "px";
FloatMenu.style.left = stmnleft+ "px";
Refreshstaticmenu ();
}
Refreshstaticmenu=function ()
{
var Stmnstartpoint,stmnendpoint,stmnrefreshtimer;
Stmnstartpoint = parseint (FloatMenu.style.top, 10);
Stmnendpoint = Document.documentElement.scrollTop + stmnGAP2;
if (Stmnendpoint < stmnGAP1) Stmnendpoint = stmnGAP1;
if (Stmnstartpoint!= stmnendpoint)
{
Stmnscrollamount = Math.ceil (Math.Abs (stmnendpoint-stmnstartpoint)/15);
FloatMenu.style.top = parseint (FloatMenu.style.top) + ((stmnendpoint<stmnstartpoint)?-stmnscrollamount: Stmnscrollamount) + "px";
Stmnrefreshtimer = Stmnscrollspeed;
}
Else
{
Stmnrefreshtimer = Stmnactivatespeed;
}
SetTimeout ("Refreshstaticmenu ();", Stmnrefreshtimer);
}
}