Document.contextual() (Method)

Returns a style object that represents the contextual style for the receiver.

Availability:

JavaScript - 1.2
Netscape - 4.0
Deprecated
Property/method value type:JSSTag object
JavaScript syntax:NmyDocument.contextual(aStyle, ...)
Argument list:aStyleOne or more style objects to clone

This method is used to instantiate a new style object for when tags occur within the tags or classes of other types. For example, you can build a contextual style object that combines two tag types and specifies that when, and only when, they are used in that context, a certain style appearance is defined.

This fragment of JavaScript will yield a style object that is relevant to the contents of an <H1> tag:

myStyle1 = document.tags.H1;

This fragment will yield a style object relevant to text inside a <B> tag (bold text):

myStyle2 = document.tags.B;

Now we can combine the two to yield a style object that applies only to content between the <B> tags when they are inside <H1> tags:

myStyle3 = document.contextual(myStyle1, myStyle2);

Finally, we can set some attribute of that style:

myStyle3.color = "Blue";

So, any text inside <B> tags inside <H1> tags will be blue.

This needs to be executed in a <SCRIPT> block in the <HEAD> portion of the document and cannot be executed after the body has commenced loading.

The result of this method call is a style object that operates within a particular context.

Warnings:

See also:Document object, Document.classes[], Document.tags[], JSSTag object