anchor and link object are sub-objects (or properties) of the document object, they represent an HTML hyperlin.
These objects have not methods, only properties.

1. anchor object

The Anchor object represents an HTML <a> tag. This object allows you to create a link to another document (with the href attribute), or to a different point in the same document (with the name attribute).
You can access an anchor by using getElementById(), or by searching through the anchors[] array of the document object.

anchor object properties

- Example with the value returned by some of these properties:
<a href="" title="Courses Web" id="idl" rel="friend" target="_blank" hreflang="us-en">Free Courses</a>
<script type="text/javascript"><!--
document.write('href - '+ document.getElementById("idl").href+ '<br />');
document.write('text - '+ document.getElementById("idl").text+ '<br />');
document.write('hreflang - '+ document.getElementById("idl").hreflang+ '<br />');
document.write('rel - '+ document.getElementById("idl").rel+ '<br />');
document.write('target - '+ document.getElementById("idl").target+ '<br />');
- The output of the code above:
href -
text - Free Courses
hreflang - us-en
rel - friend
target - _blank

2. link object

The link object represents an HTML link element.
A link element (<link>) is defined in the head section of an HTML document and it defines the relationship between two linked documents.
You can access an anchor by using getElementById().

link object properties

- Example with the value returned by some of these properties:
<title>JS object</title>
<link rel="stylesheet" type="text/css" hreflang="us-en" name="stylesheet" id="stl" href="style.css" />
<script type="text/javascript"><!--
document.write('href - '+ document.getElementById("stl").href+ '<br />');
document.write('hreflang - '+ document.getElementById("stl").hreflang+ '<br />');
document.write('rel - '+ document.getElementById("stl").rel+ '<br />');
document.write('name - '+ document.getElementById("stl").name+ '<br />');
- The result is:
href - style.css
hreflang - us-en
rel - stylesheet
name - stylesheet

Daily Test with Code Example

Which tag is used in <table> to create table header cell?
<thead> <th> <td>
  <th>Title 1</th>
  <th>Title 2</th>
Which CSS property sets the distance between lines?
line-height word-spacing margin
.some_class {
  line-height: 150%;
Which function opens a new browser window.
alert() confirm() open()
document.getElementById("id_button").onclick = function(){"");
Indicate the PHP function that returns an array with names of the files and folders inside a directory.
mkdir() scandir() readdir()
$ar_dir = scandir("dir_name");
anchor and link object

Last accessed pages

  1. Pagination Class - Script to paginate content (1435)
  2. Butterfly Kyodai (25093)
  3. Courses Web: PHP-MySQL JavaScript Ajax HTML CSS Flash-AS3 (54435)
  4. MD5 hash string in JavaScript (805)
  5. Register and show online users and visitors (16824)

Popular pages this month

  1. Bubbles3 (3397)
  2. Butterfly Kyodai (3013)
  3. Zuma Deluxe (2212)
  4. Qwop (1433)
  5. Backgammon (1307)