Dom--Anchor Object

<html>
<head>

<style type="text/css">
a:active 
{color:green}
</style>


<script type="text/javascript">
function changeLink()
{
document.getElementById('myAnchor').innerHTML
="Visit W3Schools"
document.getElementById('myAnchor').href
="http://www.w3schools.com"
document.getElementById('myAnchor').target
="_blank"
}

function getfocus()
{document.getElementById('myAnchor').focus()}

function losefocus()
{document.getElementById('myAnchor').blur()}

function access()
{
document.getElementById('myAnchor').accessKey
="a"
}


</script>
</head>

<body onload="access()">
<id="myAnchor" href="http://www.microsoft.com">Visit Microsoft</a>
<br /><br />
<input type="button" onclick="changeLink()" value="Change link">
<p>In this example we change the text and the URL of a hyperlink. We also change the target attribute.
The target attribute is by default set to "_self", which means that the link will open in the same window.
By setting the target attribute to "_blank", the link will open in a new window.
</p>
--------------------------------------------------------
<br /><br/>
<input type="button" onclick="getfocus()" value="Get focus">
<input type="button" onclick="losefocus()" value="Lose focus">

<br/>
--------------------------------------------------------
<br /><br/>

<p>(Use Alt + a to give focus to the link.)</p>

</body>

</html>
posted @ 2006-07-14 18:29  烈马狂生  阅读(241)  评论(0编辑  收藏  举报