作者zeroex2100 (Silent gardener)
看板Web_Design
标题[问题] JS控制网页上的浮动视窗
时间Tue Apr 30 17:41:06 2013
小弟本身不会写JS只会改改别人简单的成品
我看到一个浮动视窗的JS想要应用一下,但是该JS只有控制一只示窗
我想把它改成左右双边视窗
如图
http://ppt.cc/vgg_
原始的程式如下
<SCRIPT type=text/javascript>
<!--
function MM_openBrWindow(theURL,winName,features) { //v2.0
window.open(theURL,winName,features);
}
lastScrollY=0;
function rollimg(){
var varY = document.body.scrollTop;
if (varY <= 0)
{
varY = document.documentElement.scrollTop;
}
percent=.1*(varY-lastScrollY);
if(percent >0 )
percent=Math.ceil(percent);
else
percent=Math.floor(percent);
var top = parseInt(document.getElementById("floatlayer").style.top);
document.getElementById("floatlayer").style.top = (top += percent) + "px";
lastScrollY += percent;
document.getElementById("floatlayer").style.left=(document.body.clientWidth/2+405)+"px";
}
window.setInterval("rollimg()",1);
//-->
</SCRIPT>
<DIV style="POSITION: absolute; TOP: 70px; right:-100px; height: 405px;"
id="floatlayer">
<STYLE type=text/css>
#msn_box {
PADDING:0; MARGIN: 0px;width:89px;height:405px;
}
</STYLE>
<iframe src="/eweb_ta8989/html/go_idx.html" allowtransparency="true"
style="background-color=transparent" title="线上客服" frameborder="0"
width="168" height="405" scrolling="No"></iframe></DIV>
<script language="javascript">
function reSize(){
parent.document.all.getElementsByTagName("iframe").height=document.body.scrollHeight;
}
window.onload=reSize;
</script>
如果我要在左边再加入一个 floatlayer1
请问我JS的部分该怎麽写才能控制floatlayer1的位置会随着页面卷动也跟着floatlayer
位移一样的px
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 220.128.137.46
※ 编辑: zeroex2100 来自: 220.128.137.46 (04/30 17:42)