Home >Web Front-end >JS Tutorial >js scrolls floating code following the scroll bar_javascript skills

js scrolls floating code following the scroll bar_javascript skills

WBOY
WBOYOriginal
2016-05-16 18:37:471317browse
Copy code The code is 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 to scroll and float
//pObjName: html element ID
//pText:html element content
//See others for yourself
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 stmnScrollS peed = 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, 10) ((stmnEndPointstmnRefreshTimer = stmnScrollSpeed;
}
else
{
stmnRefreshTimer = stmnActivateSpeed;
}
setTimeout("RefreshStaticMenu();", stmnRefreshTimer);
}
}
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn