var loding='<div id="div_delay"><img src="images/blank2.gif"/>';
loding+='<span>'; loding+='正在存入数据,请稍候....';
loding+='</span>'; loding+='</div>';
document.getElementById("div_delay").style.width=screen.width;
document.getElementById("div_delay").style.height=screen.height;
document.getElementById("div_delay").style.backgroundColor="red";
缺少对象是为什么 div_delay得不到马?
上面正解啦,你可以把后面的样式(长宽颜色)写在loding变量中啊,拼接一个字符串
你这样写肯定不行啦,还没在页面上构建好DOM文档结构呢你就调用,肯定得不到啊
var lodingBox = $$("div");
lodingBox.style.width=screen.width;
lodingBox.style.height=screen.height;
lodingBox.style.backgroundColor="red";
var lodingImg=$$("img");
lodingImg.src="Images/loadingmin.gif";
var lodingText=$$("span");
lodingText.innerHTML="正在存入数据,请稍候....";
lodingBox.appendChild(lodingImg);
lodingBox.appendChild(lodingText);
//创建元素的方法
function $$(titleName)
{
return document.createElement(titleName);
}