HTML and CSS Reference
In-Depth Information
Table 12.4 Properties of the JavaScript links Object (continued)
Property
What It Describes
protocol
The protocol part of the URL, including the colon.
search
The query part of the URL.
target
The HTML target attribute of the link.
EXAMPLE 12.2
<html>
<title>Using Links </title></head>
<body>
<h2>Links and their Properties</h2>
<big>
1
<a href="http://search.yahoo.com/bin/search?p=JavaScript
tutorial">
Search for JavaScript Stuff</a>
<p>
2
<a href="http://google.com?" >Go to google </a>
</p><p>
3
<a href="http://www.bing.com">Go to bing </a>
</p>
<script type = "text/javascript">
document.write("<br /><b>This document contains "
+document.links.length + " links.<br /></b>");
4
for (i = 0; i< document.links.length; i++) {
5
document.write("<u>document.links["+i+"]:</u><br />");
5
document.write("<b>hostname:</b> "
+document.links[i]. hostname +"<br />");
6
document.write("<b>href: </b>"
+document.links[i]. href +"<br />");
7
document.write("<b>pathname:</b>"
+document.links[i]. pathname +"<br />");
8
document.write("<b>port:</b> "
+document.links[i]. port +"<br />");
9
document.write("<b>query string:</b> "
+document.links[i]. search +"<br />");
10
document.write("<b>protocol:</b> "
+document.links[i]. protocol +"<br /><br />");
}
</script>
</big>
</body>
</html>
 
Search WWH ::




Custom Search