Internet Explorer 6 is not supported.
Upgrade to view this site.

Referencing the Document Class

Posted on March 8, 2008 at 4:51 pm

Referencing the document class can be done in two ways. The first example uses brackets and a string. The brackets allows whatever is inside it to be ignored at compile time and used at runtime. If dot notation was used the compiler would try to find the function. It wouldn’t find the function and you would get a compiler error. The brackets hide it from the compiler and this is taken care of at runtime instead. The string, or the text in quotes, inside means that it is handled literally, letter for letter. This technique can also be used with a variable. This could be helpful if getting information at runtime. For example, if you are retrieving the name of a function from an external data source such as a XML file.

1
2
//example 1
root["functionReference"]();

The second example uses the Document Class name. This is very similar to dot syntax except the root keyword is put in parenthesis after the Document Class name. This technique can be used with properties and methods in the Document Class.

1
2
//example 2
DocumentClass(root).functionReference();
Categories
Tags

Leave a Comment

*Required fields. Email will not be published.