javascript| objects
From the first published article, until now to publish a second article, I do not think, I will not send out.
These days have been looking for JavaScript all the objects of the properties and methods, there is no way, had to write a random. First of all, if you have better can be taken out to share, get the object and then check the data, not faster?
<!--
---------------------------------------------------------
Write by Yyuj
To enumerate all member information of an object
---------------------------------------------------------
-->
<form name= "Form1" method= "POST" >
<input type= "text" name= "objname" size= "Document" >
<input type= "Submit" value= "OK" >
</form>
<script language= "JavaScript" >
<!--
function GetInfo ()
{
var Obj=document.form1;
Getobj (Obj.objname.value);
return false;
}
function Getobj (mobjname)
{
Creating variables
var objarray = new Array (); An array to store the name of the variable
var objname=mobjname; Receives the object name (character type) that is passed in from outside
Var TypeName;
--Error handling
Try
{
Enumerate all member information for an object
for (Var i in eval (objname))
{
objarray[objarray.length++] = i;
}
--Get the DIV tag for storing information
var Objinfo=document.getelementbyid ("Objinfo")
Objinfo.innerhtml= ""
Objinfo.innerhtml= "Objname:<b style= ' color= #ff0000 ' >" +objname+ "</b><br>"
--If no member exists, return
if (objarray.length==0)
{
Objinfo.innerhtml= "Objname:<b style= ' color= #ff0000 ' >" +objname+ "</b>--no member exists in existence";
Return
}
--Sort the array
Objarray.sort ();
--Further processing of output information
for (Var k=0;k<objarray.length;k++)
{
Typename=typeof (eval (objname+ ".") +OBJARRAY[K]))
--If the object is directly linked, otherwise do not show
if ("Object" ==typename)
{
objinfo.innerhtml=objinfo.innerhtml+ "|--<a href=\" javascript:getobj (' +objname+ '). +objarray[k]+ "') \" > "+objarray[k]+" </a> ==================== "+typename
}
Else
{
objinfo.innerhtml=objinfo.innerhtml+ "| |" +objarray[k]+ "====================" +typename
}
--underlined, mainly for the sake of beauty
objinfo.innerhtml=objinfo.innerhtml+ "<br>---------------------------------------------------<br>"
}
}
catch (E)
{
Alert ("You are not entering the correct object, please enter the correct object!") If it is, please enter the prefix, \ n \ nplease like, I want to query the body, then I input document.body ");
}
}
-->
</script>
<div name= "Objinfo" id= "Objinfo" ></div>