ScriptArray object (Object/browser)

A collection of script blocks belonging to a document.

Availability:

JScript - 3.0
Internet Explorer - 4.0
JavaScript syntax:IEmyScriptArray = myDocument.scripts
Object properties:length
Object methods:item()

In the example, the document contains several script blocks. The script source is extracted and formatted with an escape() function and line breaks are reinserted by means of the String.split() and Array.join() methods.

Warnings:

Example code:

   <HTML>
   <HEAD></HEAD>
   <BODY>
   <TABLE BORDER=1>
   <TH>Index</TH>
   <TH>ID</TH>
   <TH>Text</TH>
   <SCRIPT ID="ONE">
   block1 = "ONE";
   </SCRIPT>
   <SCRIPT ID="TWO">
   block2 = "TWO";
   </SCRIPT>
   <SCRIPT ID="THREE">block3 = "THREE";</SCRIPT>
   <SCRIPT ID="FOUR">
   block4 = "FOUR";
   myLength = document.scripts.length;
   for (myEnumerator=0; myEnumerator<myLength; myEnumerator++ )
   {
      mySourceText = escape(document.scripts[myEnumerator].text);
      myArray = mySourceText.split("%0D");
   
      document.write("<TR><TD>");
      document.write(myEnumerator);
      document.write("</TD><TD>");
      document.write(document.scripts[myEnumerator].id);
      document.write("</TD><TD>");
      document.write(myArray.join("%0D<BR>"));
      document.write("</TD></TR>");
   }
   </SCRIPT>
   </TABLE>
   </BODY>
   </HTML>

See also:Collection object, Document.scripts[], ScriptArray.length

PropertyJavaScriptJScriptNIEOperaNESECMADOMCSSHTMLNotes
length n/a3.0 3.0 n/a4.0 4.0 n/a n/a n/a n/a n/a n/aWarning , ReadOnly.

MethodJavaScriptJScriptNIEOperaNESECMADOMCSSHTMLNotes
item() n/a3.0 3.0 n/a4.0 4.0 n/a n/a n/a n/a n/a n/a-