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="http://coursesweb.net" 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 />');
--></script>
- The output of the code above:
href - http://coursesweb.net/
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:
<html>
<head>
<title>JS object</title>
<link rel="stylesheet" type="text/css" hreflang="us-en" name="stylesheet" id="stl" href="style.css" />
</head>
<body>
<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 />');
--></script>
</body>
</html>
- The result is:
href - style.css
hreflang - us-en
rel - stylesheet
name - stylesheet

Daily Test with Code Example

HTML
CSS
JavaScript
PHP-MySQL
Which tag defines the clickable areas inside the image map?
<map> <img> <area>
<img src="image.jpg" usemap="#map1">
<map name="map1">
  <area shape="rect" coords="9, 120, 56, 149" href="#">
  <area shape="rect" coords="100, 200, 156, 249" href="#">
</map>
Which CSS property defines what is done if the content in a box is too big for its defined space?
display overflow position
#id {
  overflow: auto;
}
Click on the event which is triggered when the mouse is positioned over an object.
onclick onmouseover onmouseout
document.getElementById("id").onmouseover = function(){
  document.write("Have Good Life");
}
Indicate the PHP variable that contains data added in URL address after the "?" character.
$_SESSION $_GET $_POST
if(isset($_GET["id"])) {
  echo $_GET["id"];
}
anchor and link object

Last accessed pages

  1. PHP-MySQL free course, online tutorials PHP MySQL code (41827)
  2. Qwop (39687)
  3. Drag Racer V3 (14587)
  4. Create simple Website with PHP (15204)
  5. Zuma Games (17987)

Popular pages this month

  1. Qwop (6862)
  2. Drag Racer V3 (4692)
  3. Bubbles3 (1916)
  4. List with All the Games (1605)
  5. Butterfly Kyodai (1507)