Re: Set Static Text value with Javascript
TIP: You can dump the function implementation with the toString method:
Gives you this:
If you run across a javascript function with no documentation, sometimes dumping its implementation and then beautifying the code can help with figuring out what it does.
Originally posted by kotinkarwak
View Post
Code:
$gvs.toString()
Code:
"function $gvs(obj){var pEle=typeof arguments[1]!='undefined'?arguments[1]:false;if(pEle=='')pEle=false;var honorHTML=typeof arguments[2]!='undefined'?arguments[2]:true;if(typeof obj=='string')obj=$n(obj);if(obj.tagName)obj=[obj];if(pEle){if(pEle.constructor==Function)obj=pEle(obj);else obj=$cetp(obj,pEle);} var tag='';var type='';var tArr=new Array();var notArray=false;for(var i=0;i<obj.length;i++){tag=obj[i].tagName.toLowerCase();if(tag=='input')type=obj[i].type.toLowerCase();else type='';if(type=='checkbox'||type=='radio'){if(obj[i].checked==true)tArr.push(obj[i].value);if((type=='checkbox'&&obj.length==1)||type=='radio')notArray=true;}else if(tag=='input'||tag=='textarea'){tArr.push(obj[i].value);notArray=true;}else if(tag=='select'){if(obj[i].multiple==true){for(var j=0;j<obj[i].options.length;j++){if(obj[i].options[j].selected==true) tArr.push(obj[i].options[j].value);}}else{tArr.push(obj[i].value);notArray=true;}}else if(tag=='img'){tArr.push(obj[i].src);}else{if(honorHTML)tArr.push(obj[i].innerHTML);else if(obj[i].textContent)tArr.push(obj[i].textContent);else if(obj[i].innerText)tArr.push(obj[i].innerText);else tArr.push(obj[i].innerHTML);notArray=true;}} if(notArray){if(tArr.length==0)return'';else return tArr[0];}else return tArr;}"
Comment