日期:2014-05-17  浏览次数:20432 次

JS 缺少对象。
JScript code




lastScrollY=0;
function heartBeat(){ 
var diffY;
if (document.documentElement && document.documentElement.scrollTop)
diffY = document.documentElement.scrollTop;
else if (document.body)
diffY = document.body.scrollTop
else
{/*Netscape stuff*/}
percent=.1*(diffY-lastScrollY); 
if(percent>0)percent=Math.ceil(percent); 
else percent=Math.floor(percent); 
document.getElementById("lovexin12").style.top=parseInt(document.getElementById
("lovexin12").style.top)+percent+"px";
document.getElementById("lovexin14").style.top=parseInt(document.getElementById
("lovexin14").style.top)+percent+"px";
lastScrollY=lastScrollY+percent; 
}



window.setInterval("heartBeat()",1);






前台

HTML code


 <script src="/js/dui.js" type="text/javascript"></script>
    <div id="lovexin12" style='left: 5px; position: absolute; top: 20px; display: none'>
    </div>
    <div id="lovexin14" style='right: 5px; position: absolute; top: 20px;'>
    </div>



IE8提示行1字符1缺少对象。




------解决方案--------------------
<script src="/js/dui.js" type="text/javascript"></script>放在页面后面或者

window.onload=function()
{
window.setInterval("heartBeat()",1);
}

另外,确保/js/dui.js路径正确