javaScript 中图片随滚动条滚动的问题 下面有详情
<divclass="scroll"id="scroll"><divclass="scroll_close"id="scroll_close"><ahref="javas...
<div class="scroll" id="scroll">
<div class="scroll_close" id="scroll_close">
<a href="javascript:scroll_close()">关闭</a></div>
<img src="images/dd_scroll9.jpg" id="scroll9" /></div>
上面是HTML代码
var scroll;
var right;
var top;
function init(){
scroll = document.getElementById("scroll");
if(scroll.currentStyle){
top = scroll.currentStyle.top;
right = scroll.currentStyle.right;
}else{
rihgt = document.defaultView.getComputedStyle(scroll,null).right;
top = document.defaultView.getComputedStyle(scroll,null).top;
}
right = parseInt(right);
top = parseInt(top);
}
function move()
{
var scrolltop = document.documentElement.scrollTop;
var scrollright = document.documentElement.scrollLeft;
scrolltop = parseInt(scrolltop);
scrollright = parseInt(scrollright);
scroll.style.top = top+scrolltop+"px";
scroll.style.right = right-scrollright+"px";
}
window.onscroll = move;
window.onload = init;
上面是javaScript代码
一运行就提示scroll.style 为空或者不是对象 大神求教啊 我急死了 展开
<div class="scroll_close" id="scroll_close">
<a href="javascript:scroll_close()">关闭</a></div>
<img src="images/dd_scroll9.jpg" id="scroll9" /></div>
上面是HTML代码
var scroll;
var right;
var top;
function init(){
scroll = document.getElementById("scroll");
if(scroll.currentStyle){
top = scroll.currentStyle.top;
right = scroll.currentStyle.right;
}else{
rihgt = document.defaultView.getComputedStyle(scroll,null).right;
top = document.defaultView.getComputedStyle(scroll,null).top;
}
right = parseInt(right);
top = parseInt(top);
}
function move()
{
var scrolltop = document.documentElement.scrollTop;
var scrollright = document.documentElement.scrollLeft;
scrolltop = parseInt(scrolltop);
scrollright = parseInt(scrollright);
scroll.style.top = top+scrolltop+"px";
scroll.style.right = right-scrollright+"px";
}
window.onscroll = move;
window.onload = init;
上面是javaScript代码
一运行就提示scroll.style 为空或者不是对象 大神求教啊 我急死了 展开
2011-06-28
展开全部
这里有一个弹出框效果
能自定义定位并随屏滚动而不抖动
里面有教程和源码
能自定义定位并随屏滚动而不抖动
里面有教程和源码
参考资料: http://www.blueidea.com/common/shoutbox/redir.asp?5=s&id=12497
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询