488 Part III ✦ Document Objects Reference Even so, these properties are now a part of the W3C DOM specification, so they are implemented in NN6 as well. One property to take special note of is language. This property name conflicts slightly with the language property that is part of all HTML element objects. The preferred way to specify the language of the script statements inside the element is to set the TYPE attribute to a MIME type. Unfortunately, this technique does not distinguish among versions of JavaScript. Also, for backward compatibility, I advise you to continue using the LANGUAGE attribute as well because only IE4+ and NN6+ recognize the TYPE attribute. Microsoft developer documentation states that the SCRIPT element object has an onLoad event handler. If that assertion is true, then it is broken in IE4 and IE5. Properties defer Value: Boolean Read/Write NN2 NN3 NN4 NN6 IE3/J1 IE3/J2 IE4 IE5 IE5.5 Compatibility ✓✓✓✓ The default process of loading a page that contains scripts is to wait for any immediate script execution to complete before the rest of the page loads. But if you include a DEFER attribute in the tag, modern browsers continue to load the rest of the page without waiting for immediate scripts to run. The defer property enables you to inspect or set that property; its default value is false. Once a page loads, any changes you make to an existing SCRIPT element’s defer property has no effect. event htmlFor Value: String Read-Only NN2 NN3 NN4 NN6 IE3/J1 IE3/J2 IE4 IE5 IE5.5 Compatibility ✓✓✓✓ Modern browsers enable you to bind events to script statements when you spec- ify both a FOR and EVENT attribute in the <SCRIPT> tag. Statements inside the tag execute only when the object named by the FOR attribute receives the event named by the EVENT attribute. You can examine the EVENT attribute by way of the SCRIPT element object’s event property, and you can view the FOR attribute through the Note SCRIPT.event 489 Chapter 20 ✦ HTML Directive Objects htmlFor property. Both properties simply mimic whatever values are assigned to their respective attributes, such as onClick() and myDIV. language Value: String Read/Write NN2 NN3 NN4 NN6 IE3/J1 IE3/J2 IE4 IE5 IE5.5 Compatibility ✓✓✓✓ Use the language property to get or set the name of the scripting language specified for a SCRIPT element object. Even though NN and IE browsers default to JavaScript (or some equivalent), the property has no value unless you set the LANGUAGE attribute in the <SCRIPT> tag. If you must specify a particular version of JavaScript, you can do so by appending the version number immediately after the language name: document.getElementById(“myScript”).language = “JavaScript1.5” IE accepts several language names as values for this property: JavaScript, JScript, VBScript, and VBS. For IE5, XML is also accepted. Also see the type property. src Value: String Read-Only NN2 NN3 NN4 NN6 IE3/J1 IE3/J2 IE4 IE5 IE5.5 Compatibility ✓✓✓✓ The src property is a string of the URL of an external .js script file to be linked into a page. You cannot change this property after you load the external script. text Value: String Read-Only NN2 NN3 NN4 NN6 IE3/J1 IE3/J2 IE4 IE5 IE5.5 Compatibility ✓✓✓✓ The full text of a SCRIPT element is available for reading through the text property. While IE5 may give the impression that you can modify this property, the script that loads with the page is what is stored in the browser’s memory. Thus, the original script statements continue to work even though the object’s property is different. SCRIPT.text 490 Part III ✦ Document Objects Reference type Value: String Read-Only NN2 NN3 NN4 NN6 IE3/J1 IE3/J2 IE4 IE5 IE5.5 Compatibility ✓✓✓✓ The TYPE attribute was added to the <SCRIPT> tag in HTML 4.0 to help resolve the conflict that the LANGUAGE attribute created for all HTML elements. The value of the attribute (and thus the type property) is a MIME type string. For JavaScript, that value is text/javascript. TITLE Element Object For HTML element properties, methods, and event handlers, see Chapter 15. Properties Methods Event Handlers text Syntax Accessing TITLE element object properties or methods: (IE4+) [window.]document.all.elemID.property | method([parameters]) (IE5+/NN6) [window.]document.getElementById(“elemID”).property | method([parameters]) About this object Before the TITLE element was accessible to scripting as an object, the prescribed way to get to the content of the page’s <TITLE> tag was through the document. title property. While that property is still available for backward compatibility, scripts written exclusively for newer browsers should access the text property of the TITLE element object. As a useful exercise, you can modify Listing 18-17 (loaded via Listing 18-16) to use the IE4+ or W3C DOM syntax to retrieve and display the document’s title. Property text Value: String Read/Write NN2 NN3 NN4 NN6 IE3/J1 IE3/J2 IE4 IE5 IE5.5 Compatibility ✓✓✓✓ TITLE.text 491 Chapter 20 ✦ HTML Directive Objects The text property represents the text between the start and end tags of the TITLE element object. This is simply a convenience property because the text can be referenced by other ways in IE4+ ( innerText property), NN6 (innerHTML), and W3C DOM ( firstChild.nodeValue) syntaxes. For backward compatibility with earlier browsers, you can alternatively use the document.title property. Related Items: document.title property. ✦✦✦ TITLE.text . default to JavaScript (or some equivalent), the property has no value unless you set the LANGUAGE attribute in the <SCRIPT> tag. If you must specify a particular version of JavaScript, . navigating to another URL, you can use a special technique —the javascript: pseudo-URL —to direct the URL to a JavaScript function. The URL javascript: functionName() is a valid parameter for the HREF attribute. content of more than one frame at once with the help of JavaScript. If you want only JavaScript- enabled browsers to act on such links, use a javascript: pseudo-URL to invoke a function that changes