大家帮我看看这个js为什么老是报对象未定义或对象为null值var scrolltop;
var scrollleft;
function initial() //实例化
{
var div=document.getElementById("scroll_pic"); //就是这个老是找不到对象
scrolltop=parseInt(div.currentStyle.top);
showpic(); //实例化图片轮换
scrollpic();
//setTimeout("window.open('open.html')",5000); //弹窗 }function scrollpic() //对联广告
{var div=document.getElementById("scroll_pic"); //就是这个老是找不到对象div.style.top=parseInt(document.documentElement.scrollTop)+scrolltop+"px";
}
具体文件我也传上来,希望有那么个大神帮我看看到底是什么原因; 最近才学的js。需要高手的支持和爱护呀!! 小弟在此先谢谢前辈了!!!
问题包在这:http://down.51cto.com/data/654166 找不到加附件的地方,版主不是我想加外链的。。divjavascriptfunctionscroll
var scrollleft;
function initial() //实例化
{
var div=document.getElementById("scroll_pic"); //就是这个老是找不到对象
scrolltop=parseInt(div.currentStyle.top);
showpic(); //实例化图片轮换
scrollpic();
//setTimeout("window.open('open.html')",5000); //弹窗 }function scrollpic() //对联广告
{var div=document.getElementById("scroll_pic"); //就是这个老是找不到对象div.style.top=parseInt(document.documentElement.scrollTop)+scrolltop+"px";
}
具体文件我也传上来,希望有那么个大神帮我看看到底是什么原因; 最近才学的js。需要高手的支持和爱护呀!! 小弟在此先谢谢前辈了!!!
问题包在这:http://down.51cto.com/data/654166 找不到加附件的地方,版主不是我想加外链的。。divjavascriptfunctionscroll
可能是元素还没加载进来就先运行你的代码了吧?
是同一个js。故头部找不到这个id。当执行到第二遍就可以找到的