首頁 > web前端 > js教程 > js跟随滚动条滚动浮动代码_javascript技巧

js跟随滚动条滚动浮动代码_javascript技巧

WBOY
發布: 2016-05-16 18:37:47
原創
1310 人瀏覽過
复制代码 代码如下:

var str="客服";
var objFT=new FloatT("FloatMenu1",str,942,137,125,200,80,10);
objFT.FloatRun();


//js跟随滚动条滚动 浮动
//pObjName:html 元素ID
//pText:html 元素内容
//其它自己看
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
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);
}
}
相關標籤:
來源:php.cn
本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
最新問題
熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板