js 中onscroll怎么会出现这种效果?火狐浏览器,ie中没有问题,
代码是functionautoNextPage(){vartmpimg,topHeight,bottomHeight,spanlist,tmph;varspanPre=$...
代码是
function autoNextPage(){
var tmpimg,topHeight,bottomHeight,spanlist,tmph;
var spanPre=$id("spanPre");
var spanNext=$id("spanNext");
var spanTop,iis=0
var top=(document.documentElement.scrollTop||document.body.scrollTop)-250;
var screenH= window.screen.height;
if (!spanPre) { spanlist=$tagN("span");spanPre=$class(spanlist,"pro_pic fixPng")[0];}
if (!spanNext){spanlist=spanlist||$tagN("span");spanNext=$class(spanlist,"next_pic fixPng")[0];}
tmpimg=document.getElementById("imgString").getElementsByTagName("img")
bottomHeight=tmpimg[tmpimg.length-1].offsetHeight+tmpimg[tmpimg.length-1].offsetTop;
topHeight=tmpimg[0].offsetTop
screenH=400 ;//(document.documentElement.clientHeight )/2;
//alert(tmpimg[0].clientHeigh)
//topHeight=200+"px";
if(top<150){
spanTop=topHeight+150;iis=1
}else if(top>(bottomHeight-250-spanPre.offsetHeight)){
spanTop=bottomHeight-spanPre.offsetHeight-250;iis=2
}else{
spanTop=topHeight+top;iis=3
}
//spanTop=top-spanPre.offsetHeight-150;
//spanTop+=screenH-280;
spanTop+=(screenH-280);
$id("sss").innerHTML=top+',spanTop='+spanTop +','+spanTop +','+bottomHeight+',spanPre.offsetHeight='+(spanPre.offsetHeight)+',iis='+iis+","+(topHeight+150)
spanPre.style.marginTop=spanTop+"px";
//spanPre.style.marginTop=spanTop;
spanNext.style.marginTop=spanTop+"px";
//spanNext.style.marginTop=spanTop;
}
window.onscroll=autoNextPage;
html代码
<style>
.picbox {height:auto;min-height:2px;overflow:hidden;width:100%;z-index: 6;}
.pro_pic {width:102px;height:102px;margin-top:151px;position:absolute;z-index: 100; cursor: pointer;}
.next_pic { width: 102px; height: 102px; margin-top: 151px; position:absolute; z-index: 100; cursor: pointer;}
.pro_pic {background: url("/images/picLeft.png") no-repeat left top; left: 30px;}
.next_pic {background: url("/images/picRight.png") no-repeat left top; right: 30px;}
</style>
<div class="picbox">
<span id="spanPre" class="pro_pic fixPng" onclick="dPlayPre();" style="margin-top: 526px;"></span>
<span id="spanNext" class="next_pic fixPng" onclick="dPlayNext()" style="margin-top: 526px;"></span></div> 展开
function autoNextPage(){
var tmpimg,topHeight,bottomHeight,spanlist,tmph;
var spanPre=$id("spanPre");
var spanNext=$id("spanNext");
var spanTop,iis=0
var top=(document.documentElement.scrollTop||document.body.scrollTop)-250;
var screenH= window.screen.height;
if (!spanPre) { spanlist=$tagN("span");spanPre=$class(spanlist,"pro_pic fixPng")[0];}
if (!spanNext){spanlist=spanlist||$tagN("span");spanNext=$class(spanlist,"next_pic fixPng")[0];}
tmpimg=document.getElementById("imgString").getElementsByTagName("img")
bottomHeight=tmpimg[tmpimg.length-1].offsetHeight+tmpimg[tmpimg.length-1].offsetTop;
topHeight=tmpimg[0].offsetTop
screenH=400 ;//(document.documentElement.clientHeight )/2;
//alert(tmpimg[0].clientHeigh)
//topHeight=200+"px";
if(top<150){
spanTop=topHeight+150;iis=1
}else if(top>(bottomHeight-250-spanPre.offsetHeight)){
spanTop=bottomHeight-spanPre.offsetHeight-250;iis=2
}else{
spanTop=topHeight+top;iis=3
}
//spanTop=top-spanPre.offsetHeight-150;
//spanTop+=screenH-280;
spanTop+=(screenH-280);
$id("sss").innerHTML=top+',spanTop='+spanTop +','+spanTop +','+bottomHeight+',spanPre.offsetHeight='+(spanPre.offsetHeight)+',iis='+iis+","+(topHeight+150)
spanPre.style.marginTop=spanTop+"px";
//spanPre.style.marginTop=spanTop;
spanNext.style.marginTop=spanTop+"px";
//spanNext.style.marginTop=spanTop;
}
window.onscroll=autoNextPage;
html代码
<style>
.picbox {height:auto;min-height:2px;overflow:hidden;width:100%;z-index: 6;}
.pro_pic {width:102px;height:102px;margin-top:151px;position:absolute;z-index: 100; cursor: pointer;}
.next_pic { width: 102px; height: 102px; margin-top: 151px; position:absolute; z-index: 100; cursor: pointer;}
.pro_pic {background: url("/images/picLeft.png") no-repeat left top; left: 30px;}
.next_pic {background: url("/images/picRight.png") no-repeat left top; right: 30px;}
</style>
<div class="picbox">
<span id="spanPre" class="pro_pic fixPng" onclick="dPlayPre();" style="margin-top: 526px;"></span>
<span id="spanNext" class="next_pic fixPng" onclick="dPlayNext()" style="margin-top: 526px;"></span></div> 展开
2个回答
展开全部
您好!很高兴为您答疑!
火狐下的兼容问题,应当把要在onscroll中执行的函数就放在此处执行就行了。现在你的要求“鼠标放到这里面并滚动滚轮并执行事件”,如(onmousewheel/DOMMouseScroll),因为滚动滚轮滚动条也是应该能动的!
您可以在火狐社区了解更多内容。希望我的回答对您有所帮助,如有疑问,欢迎继续在本平台咨询。
火狐下的兼容问题,应当把要在onscroll中执行的函数就放在此处执行就行了。现在你的要求“鼠标放到这里面并滚动滚轮并执行事件”,如(onmousewheel/DOMMouseScroll),因为滚动滚轮滚动条也是应该能动的!
您可以在火狐社区了解更多内容。希望我的回答对您有所帮助,如有疑问,欢迎继续在本平台咨询。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
什么效果啥或是除了什么问题,你描述下啥。
追问
我把网址用私信发给你吧,帮我看看,我怕被屏蔽就不在这里发网址了
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询