标题:JS实现sleep功能 JS遍历document对象
/*****************************************/
var elementName;
function countTotalElement(node)
{
if(node.nodeType ==1) {
elementName = elementName + node.nodeValue + "\r\n";
}
var childrens = node.childNodes;
for(var i=0;i<childrens.length;i++)
{
countTotalElement(childrens[i]);
}
}
/*js实现sleep功能 单位:毫秒*/
function sleep(numberMillis) {
var now = new Date();
var exitTime = now.getTime() + numberMillis;
while (true) {
now = new Date();
if (now.getTime() > exitTime)
return;
}
}
/*遍历网页中的div元素的id号*/
function getTotalDiv()
{
var strDivID;
strDivID="";
var arrayDiv= document.getElementsByTagName("div");
for (var i=0;i<arrayDiv.length;i++)
{
strDivID+=arrayDiv[i].id+";";
}
alert(strDivID);
}
getTotalDiv();
/************************************/
关键词:JS实现sleep功能 JS遍历document对象