abbr.horizontal reference horizontal reference, horizontal datum

javascript href attribute syntax

Function: Set or return the URL of the linked resource.

Syntax: anchorObject.href=URL

javascript href attribute example

<html>
<head>
    <meta charset="UTF-8">
    <script type="text/javascript">
        function changeLink()
        {
            document.getElementById('myAnchor').innerHTML="訪問 phpStudy"
            document.getElementById('myAnchor').href="http://www.phpStudy.net"
            document.getElementById('myAnchor').target="_blank"
        }
    </script>
</head>

<body>
<a id="myAnchor" href="http://miracleart.cn">訪問 php中文網(wǎng)</a>
<input type="button" onclick="changeLink()" value="改變鏈接">
<p>在本例中,我們改變超鏈接的文本和 URL。我們也改變 target 屬性。target 屬性的默認(rèn)設(shè)置是 "_self",這意味著會在相同的窗口中打開鏈接。通過把 target 屬性設(shè)置為 "_blank",鏈接將在新窗口中打開。</p>
</body>

</html>

Run instance ?

Click the "Run instance" button to view the online instance