Copy codeThe Code is as follows:
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)
{
StmnScrollAmount = Math. ceil (Math. abs (stmnEndPoint-stmnStartPoint)/15 );
FloatMenu. style. top = parseInt (FloatMenu. style. top, 10) + (stmnEndPoint <stmnStartPoint )? -StmnScrollAmount: stmnScrollAmount) + "px ";
StmnRefreshTimer = stmnScrollSpeed;
}
Else
{
StmnRefreshTimer = stmnActivateSpeed;
}
SetTimeout ("RefreshStaticMenu ();", stmnRefreshTimer );
}
}