JavaScript DHTML/Development/Object Property

Материал из Web эксперт
Перейти к: навигация, поиск

Displaying the Navigator"s Associative Array

<HTML>
<HEAD>
<TITLE>Associative object arrays</TITLE>
<SCRIPT> 
function showProperties (theObject){ 
   for (i in theObject) { 
      if (theObject[i] != null) { 
          document.write(i + " : " + theObject[i] + "<br>"); 
      } else { 
         document.write(i + "<br>"); 
      } 
   } 
   return; 
} 
</SCRIPT>
</HEAD>
<BODY>
<SCRIPT> 
showProperties(window.navigator); 
// showProperties(window.document); 
</SCRIPT>
</HTML>



Property Inspector Function

<HTML>
<HEAD>
<SCRIPT LANGUAGE="JavaScript">
function showProps(obj,objName) {
    var result = ""
    for (var i in obj) {
        result += objName + "." + i + " = " + obj[i] + "<BR>"
    }
    return result
}
</SCRIPT>
</HEAD>
<BODY>
<B>Here are the properties of the current window:</B><P>
<SCRIPT LANGUAGE="JavaScript">
document.write(showProps(window, "window"))
</SCRIPT>
</BODY>
</HTML>