JavaScript DHTML/Development/Object Property

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

Displaying the Navigator"s Associative Array

   <source lang="html4strict">

<HTML> <HEAD> <TITLE>Associative object arrays</TITLE> <SCRIPT> function showProperties (theObject){

  for (i in theObject) { 
     if (theObject[i] != null) { 
         document.write(i + " : " + theObject[i] + "
"); } else { document.write(i + "
"); } } return;

} </SCRIPT> </HEAD> <BODY> <SCRIPT> showProperties(window.navigator); // showProperties(window.document); </SCRIPT> </HTML>

      </source>
   
  


Property Inspector Function

   <source lang="html4strict">

<HTML> <HEAD> <SCRIPT LANGUAGE="JavaScript"> function showProps(obj,objName) {

   var result = ""
   for (var i in obj) {
       result += objName + "." + i + " = " + obj[i] + "
" } return result

} </SCRIPT> </HEAD> <BODY>

Here are the properties of the current window:

<SCRIPT LANGUAGE="JavaScript"> document.write(showProps(window, "window")) </SCRIPT> </BODY> </HTML> </source>