日期:2014-05-16  浏览次数:20354 次

JS代码首次打开,,缺少对象
第一次打开网页  
下面中的代码
var   d   =   document;
总是提示缺少对象,,是怎么回事

var   startX   =3,
startY   =   250;
var   ns   =   (navigator.appName.indexOf( "Netscape ")   !=   -1);
var   d   =   document;
function   ml(id)
{
var   el=d.getElementById?d.getElementById(id):d.all?d.all[id]:d.layers[id];
if(d.layers)el.style=el;
el.sP=function(x,y){this.style.left=x;this.style.top=y;};
el.x   =   startX;
if   (verticalpos== "fromtop ")
el.y   =   startY;
else{
el.y   =   ns   ?   pageYOffset   +   innerHeight   :   document.body.scrollTop   +   document.body.clientHeight;
el.y   -=   startY;
}
return   el;
}

------解决方案--------------------
<script language=javascript defer>
//后面加defer
------解决方案--------------------
var d;
function ml(id)
{
d = document;