linkNN 6 IE 4 DOM 1  

  

The link object reflects the link element. Note that many of the properties listed here are not available for scripting in the object unless their corresponding attributes are set initially in the HTML tag. Moreover, because the element's attributes act as directives while the document loads, assigning new values to the corresponding properties generally has no effect (even though the properties are read/write). This includes: href, rel, rev, and type. The media property is not available in the Macintosh version of IE 4. As a reminder, the disabled property (described among the shared properties earlier in this chapter) lets all supporting browsers turn on and off a linked style sheet.

 
HTML Equivalent
 
<link>
 
Object Model Reference
 
[window.]document.getElementById("elementID")
 
Object-Specific Properties
 
charsethrefhreflangmediarel
revsheetstyleSheettargettype
 
Object-Specific Methods

None.

 
Object-Specific Event Handler Properties
 
HandlerNNIE/WindowsIE/MacDOM
onerrorn/a4n/an/a
onloadn/a4n/an/a
charsetNN 6 IE 4 DOM 1  

Read/Write  

Indicates the character encoding of the content at the other end of the link.

 
Example
 
var charCoding = document.getElementById("myLink").charset;
 
Value

Case-insensitive alias from the character set registry (ftp://ftp.isi.edu/in-notes/iana/assignments/character-sets).

 
Default

None.

disabledNN 6 IE 4 DOM 1  

Read/Write  

Specifies whether the element is available for user interaction. When set to true, the element cannot receive focus or be modified by the user, and it typically appears grayed out on the page. This property is available for all HTML element objects in IE 5.5 for Windows and later. For IE 4 and IE 5, it applies only to form controls, while Netscape 6 and later recognize the property for form controls and the style element object. A disabled form control's name/value pair is not submitted with its form.

 
Example
 
document.getElementById("myButton").disabled = true;
 
Value

Boolean value: true | false.

 
Default

false

hrefNN 6 IE 4 DOM 1  

Read/Write  

Provides the URL specified by the element's href attribute. In IE/Windows, you can assign a new URL to this property to load in an alternate style sheet after the fact.

 
Example
 
document.getElementById("styleLink").href = "altStyles.css";
 
Value

String of complete or relative URL.

 
Default

None.

disabledNN 6 IE 4 DOM 1  

Read/Write  

Specifies whether the element is available for user interaction. When set to true, the element cannot receive focus or be modified by the user, and it typically appears grayed out on the page. This property is available for all HTML element objects in IE 5.5 for Windows and later. For IE 4 and IE 5, it applies only to form controls, while Netscape 6 and later recognize the property for form controls and the style element object. A disabled form control's name/value pair is not submitted with its form.

 
Example
 
document.getElementById("myButton").disabled = true;
 
Value

Boolean value: true | false.

 
Default

false

hreflangNN 6 IE 6 DOM 1  

Read/Write  

Specifies the language code of the content at the destination of a link. Requires that the href attribute or property also be set.

 
Example
 
document.getElementById("myLink").hreflang = "DE";
 
Value

Case-insensitive language code.

 
Default

None.

mediaNN 6 IE 4 DOM 1  

Read/Write  

Specifies the intended output device for the content of the destination document pointed to by the href attribute. The media property looks forward to the day when browsers are able to tailor content to specific kinds of devices such as pocket computers, text-to-speech digitizers, or fuzzy television sets. This property is not available in IE 4/Macintosh.

 
Example
 
if (document.getElementById("link3").media == "print") {
    // process for print output
}
 
Value

Any one of the following constant values as a string: all | print | screen.

 
Default

all

readyStateNN 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.

relNN 6 IE 4 DOM 1  

Read/Write  

Defines the relationship between the current element and the external item pointed to by the link. Also known as a forward link, not to be confused in any way with the destination document whose address is defined by the href attribute. This property is not fully exploited in mainstream browsers, but you can treat the attribute as a kind of parameter to be checked and/or modified under script control. See the discussion of the a element's rel attribute in Chapter 8 for a glimpse of how this property may be used in the future.

 
Example
 
if (document.getElementById("link3").rel == "alternate stylesheet") {
    // process for alternate style sheet
}
 
Value

Case-insensitive, space-delimited list of HTML 4 standard link types (as a single string) applicable to the element. Sanctioned link types are:

 
alternateappendixbookmarkchapter
contentscopyrightglossaryhelp
indexnextprevsection
startstylesheetsubsection
 
Default

None.

revNN 6 IE 4 DOM 1  

Read/Write  

Defines the relationship between the current element and the destination of the link. Also known as a reverse link. This property is not fully exploited in mainstream browsers, but you can treat the attribute as a kind of parameter to be checked and/or modified under script control. See the discussion of the a element's rev attribute in Chapter 8 for a glimpse of how this property may be used in the future.

 
Value

Case-insensitive, space-delimited list of HTML 4 standard link types (as a single string) applicable to the element. See the rel property for sanctioned link types.

 
Default

None.

sheetNN 6 IE n/a DOM 1  

Read-only  

Returns a reference to the styleSheet object (CSSStyleSheet object in W3C DOM terminology) linked into the current document when a style sheet is specified as the target of the link element. IE for Windows provides a similar property: styleSheet.

 
Example
 
var extSS = document.getElementById("link3").sheet;
 
Value

styleSheet object reference.

 
Default

None.

styleSheetNN n/a IE 5(Win) DOM n/a  

Read-only  

This nonstandard convenience property returns a reference to the styleSheet object linked into the current document when a style sheet is specified as the target of the link element. Netscape 6 provides a similar property: sheet.

 
Example
 
var extSS = document.getElementById("link3").styleSheet;
 
Value

styleSheet object reference.

 
Default

None.

targetNN 6 IE 4 DOM 1  

Read/Write  

Indicates the window or frame name to be the recipient of linked content. Default value (equivalent of _self) is the desired setting for linked style sheets.

 
Example
 
document.getElementById("link4").target = "frame2";
 
Value

String value of the window or frame name, or any of the following constants (as a string): _parent | _self | _top | _blank.

 
Default

None.

typeNN 6 IE 4 DOM 1  

Read/Write  

Indicates an advisory MIME type declaration about the data being loaded from an external source. For example, an external style sheet would be text/css. This information is usually set in the element tag's type attribute.

 
Example
 
if (document.getElementById("myStyle").type == "text/css") {
    ...
}
 
Value

MIME type string.

 
Default

None.