Technical Training
JavaScript TutorialJavaScript Link and Anchor Objects
JavaScript Browser Objects
Link Object:
Link object is also a property of the document object. The link object is used to get or capture a text or image link present in a document. Similar to the anchor object having anchor array, all the links are contained in link array.
Properties of Link Object:
The link object has all the properties of the location object such as; hash, host, hostname, href, pathname, port, protocol and search. Additionally, link object has one more property called target property. The target property is used to identify the window where the document referenced by the link's URL loads.
The most popularly used Internet Explorer browser, supports both anchor object and link object. Because of this association, the programmer might have a question in differentiating between the two. The href property of anchors object sets the anchor that represents the link and when the name property is set, it indicates a named anchor.
Methods of Link Object:
There is only one method present in the link object named handleEvent(). The argument given in this method is an event object, thus invoking the associated event handler for that event.
There is an anchor() method associated with the string object and, additionally, there is another method of string object called the link() method. The link() method of string object takes HREF attribute of link as parameter and creates a link to the given HREF.
This can be written as follows:
|
The above example generates HTML, thus creating a link for the current document with the given HREF.
Anchor Object:
The anchor object accesses the target of a hypertext link since it keeps track of all named offsets defined in respect to the HTML document. The anchor object has no associated properties, methods or events. It is actually a property of the document object. All the anchors of a particular document are contained in anchor array, so this is used for accessing anchor objects within a document. There is an anchor() method associated with the string object, used for creating an anchor in a current document.
This can be written as follows:
|
The above example creates the named anchor in the current document.
JavaScript Tutorial
- JavaScript Browser Objects Part 2
- JavaScript Frame object
- JavaScript Form Object
- JavaScript FileUpload Object
- JavaScript Event Object Properties and Methods
- JavaScript Event Object
- JavaScript Elements and Embed Objects
- JavaScript Applet Objects
- JavaScript Browser Objects
- JavaScript Object Oriented Features
- JavaScript Window Object Open Method Part 2
- JavaScript Window Object Open Method
- JavaScript Window Object Timeout Methods
- JavaScript Location Object
- JavaScript Location Object Properties
- JavaScript History Object Properties and Methods
- JavaScript Document Object Methods Part II
- JavaScript Document Object Methods Part I
- JavaScript Document Object Properties
- JavaScript Document Object
- JavaScript Windows Object Properties Part II
- JavaScript Windows Object Properties Part I
- JavaScript DOM Window Object
- Working with JavaScript DOM Objects
- JavaScript Array Object Methods – Part II
- JavaScript Array Object
- JavaScript Array Object Methods – Part I
- JavaScript Boolean Object
- JavaScript OnError Event
- JavaScript Exception Handling – Part II
- JavaScript Exception Handling – Part I
- JavaScript Event Handler
- JavaScript Events Handling
- JavaScript Array Operations
- JavaScript Two Dimensional Arrays
- Passing values to JavaScript Function
- JavaScript Functions
- JavaScript Arrays
- JavaScript Iterative Structures - Part II
- JavaScript Iterative Structures - Part I
- JavaScript Math Object
- JavaScript Date Object
- JavaScript String Object
- JavaScript Objects
- JavaScript Confirm Box
- JavaScript Alert Box
- JavaScript Conditional Statements Part 2
- JavaScript Conditional Statements Part 1
- How to use JavaScript in HTML page
- JavaScript Variables
- JavaScript Features
- JavaScript Introduction







