function getCurrentStyle(node,attr){if(node.currentStyle){return node.currentStyle.attr;}else{return getComputedStyle(node,nill)["attr"];
}}function traverse(nodes){var arr=[];
for(var i=0,len=nodes.length;i<len;i++){var node_width=paseInt(getCurrentStyle(nodes[i],width));var node_height=paseInt(getCurrentStyle(nodes[i],height));if(node_width<=50&&node_height<=50){arr.push(nodes[i]);
}
if(nodes[i].hasChildNodes()){arr=arr.concat(traverse(nodes[i].children));}
}
return arr;
}traverse(document.body.children);
function traverse(oNode) { var aResult = []; oNode = oNode || document.body; if (oNode.style) { var nWidth = window.parseInt(oNode.style.width, 10) || 0; var nHeight = window.parseInt(oNode.style.height, 10) || 0; if (nWidth > 50 && nHeight > 50) { aResult.push(oNode); } } var aChildNodes = oNode.childNodes; if (aChildNodes.length > 0) { for (var i = 0, l = aChildNodes.length; i < l; i++) { var oTmp = aChildNodes[i]; aResult = aResult.concat(traverse(oTmp)); } } return aResult; }
function tranverse() { let arr = [] function tranverseRecur(nodes) { Array.from(nodes).forEach(node=> { if(node.offsetWidth > 50 && node.offsetHeight > 50){ arr.push(node) } if(node.childNodes && node.childNodes.length > 0) { tranverseRecur(node.childNodes); } }) } let nodes = (document.body.childNodes); tranverseRecur(nodes); return arr; }
function traverse(el) {if (!el) {el = document.getElementsByTagName('body')[0]}var style = window.getComputedStyle(el)if (style.width.replace('px', '') > 50 && style.height.replace('px', '') > 50) {console.log(el)}if (el.children) {var index = -1while (++index < el.children.length) {traverse(el.children[index])}}}
function travaerse() { var body = document.body; var nodes = []; var filter = { acceptNode(node) { let style = document.defaultView.getComputedStyle(node, null); if (Number.parseFloat(style.width) > 50 && Number.parseFloat(style.height) > 50) { return NodeFilter.FILTER_ACCEPT; } else { return NodeFilter.FILTER_SKIP; } } } var iterator = document.createNodeIterator(body, NodeFilter.SHOW_ELEMENT, filter, false); var node = iterator.nextNode(); while (node !== null) { nodes.push(node); } return nodes; }
function traverse() { var tags = document.getElementsByTagName('*'); var tagLen = tags.length; for (var i = 0; i < tagLen; i++) { var curr = tags[i]; var width = curr.clientWidth, height = curr.clientHeight; if (width > 50 && height > 50) { console.log(curr); } } }
function traverse(elem){ var nodeArr = [] recursive(elem) function recursive(poNode){ var chileElems = poNode.children, len =chileElems.length, i = 0; h = poNode.offsetHeight, w = poNode.offsetWidth; if( h > 50 && w > 50 ){ nodeArr.push(poNode) } if( len != 0 ){ for( ; i < len; i++ ){ recursive(chileElems[i]) } } } return nodeArr; } console.log(traverse(document.body));