script | NN 6 IE 4 DOM 1 | |||||||||||
The script object reflects the script element. Internet Explorer 4 for Windows chokes on accessing or setting the innerHTML or innerText properties, but the equivalent text property is safe. IE 5 for the Macintosh implements the readyState property (shared among all elements in IE for Windows) for this object. |
||||||||||||
HTML Equivalent | ||||||||||||
<script> |
||||||||||||
Object Model Reference | ||||||||||||
[window.]document.getElementById("elementID")
|
||||||||||||
Object-Specific Properties | ||||||||||||
|
||||||||||||
Object-Specific Methods | ||||||||||||
None. |
||||||||||||
Object-Specific Event Handler Properties | ||||||||||||
|
charset | NN 6 IE 6(Win) DOM 1 |
Read/Write | |
Indicates the character encoding of the script content. |
|
Example | |
if (document.getElementById("myScript").charset == "csISO5427Cyrillic") { // process for Cyrillic charset } |
|
Value | |
Case-insensitive alias from the character set registry (ftp://ftp.isi.edu/in-notes/iana/assignments/character-sets). |
|
Default | |
Determined by browser. |
defer | NN 6 IE 4 DOM 1 |
Read/Write | |
Specifies whether the browser should proceed with rendering regular HTML content without looking for the script to generate content as the page loads. This value needs to be set in the script element's tag at runtime. When this property is set to true by the addition of the DEFER attribute to the tag, the browser does not have to hold up rendering further HTML content to parse the content of the script element in search of document.write( ) statements. Changing this property's value after the document loads does not affect the performance of the script or browser. Although Netscape 6 implements the property, it is not functional. |
|
Example | |
if (document.getElementById("myScript").defer = = "true") { ... } |
|
Value | |
Boolean value: true | false. |
|
Default | |
false |
event | NN 6 IE 4 DOM 1 |
Read-only | |
Internet Explorer's event model allows binding of object events to script elements with the help of the event and for attributes (see Chapter 6). The event property returns the setting for the event attribute. Not functional in Netscape 6. |
|
Example | |
if (document.getElementById("gizmoScript").event == "onresize") { ... } |
|
Value | |
Case-sensitive event name string. |
|
Default | |
None. |
htmlFor | NN 6 IE 4 DOM 1 |
Read-only | |
Returns the value (element ID) assigned to the for attribute of a script element. This attribute points to the ID of the element to which the script is bound when a specific event (set by the event attribute) fires for the element. Not functional in Netscape 6. |
|
Example | |
if (document.getElementById("helpScript").htmlFor == "helpButton") { ... } |
|
Value | |
String. |
|
Default | |
None. |
readyState | NN n/a IE 4 DOM n/a |
Read-only | |
Returns the current download status of the object's content. If a script (especially one initiated by a user event) can perform some actions while the document is still loading, but must avoid other actions until the entire page has loaded, this property provides intermediate information about the loading process. You should use its value in condition tests. The value of this property changes during loading as the loading state changes. Each change of the property value fires an onReadyStateChange event (the event does not bubble). |
|
When introduced with IE 4, the property was available for only the document, embed, img, link, object, script, and style objects. IE 5 expanded coverage to all HTML element objects. |
|
Example | |
if (document.readyState == "loading") { //statements for alternate handling while loading } |
|
Value | |
For all but the object element, one of the following values (as strings): uninitialized | loading | loaded | interactive | complete. Some elements may allow the user to interact with partial content, in which case the property may return interactive until all loading has completed. Not all element types return all values in sequence during the loading process. The object element returns numeric values for these five states. They range from 0 (uninitialized) to 4 (complete). |
|
Default | |
None. |
src | NN 6 IE 4 DOM 1 |
Read/Write | |
Provides the URL of the .js script file imported into the current script element. If you assign a new .js file to an existing script element in IE, the previous .js file's scripts do not disappear. But any duplications of variable or functions names are overwritten by the definitions from the new file. While Netscape 6 and later do not complain when you assign a new value to this property, the assignment does not necessarily load the new scripts into the current window or frame. |
|
Example | |
if (document.getElementsByTagName("script")[1].src == "scripts/textlib.js") { ... } |
|
Value | |
Complete or relative URL as a string. |
|
Default | |
None. |
text | NN 6 IE 4 DOM 1 |
Read/Write | |
Indicates the text content of the element. Assigning script statements to this object has different results in various browsers. In late versions of IE for Windows, the new value is added to the existing script, even though the property no longer reports the previous script text; in Netscape 6, the assigned values are ignored; and in IE 5 for Macintosh, the property is treated as read-only. |
|
Example | |
var scriptText = document.getElementById("script3").text; |
|
Value | |
String. |
|
Default | |
None. |
type | NN 6 IE 4 DOM 1 |
Read-only | |
Provides an advisory about the content type of the script statements. The content type should tell the browser which scripting engine to use to interpret the script statements, such as text/javascript. The type attribute may eventually replace the language attribute as the one defining the scripting language in which the element's statements are written. |
|
Example | |
var scriptMIMEtype = document.getElementById("script3").type; |
|
Value | |
String. |
|
Default | |
None. |