abr.référence horizontale référence horizontale, référence horizontale

attribut javascript href syntaxe

Fonction?: Définissez ou renvoyez l'URL de la ressource liée.

Syntaxe?: anchorObject.href=URL

attribut javascript href exemple

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

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

</html>

Exécuter l'instance ?

Cliquez sur le bouton ??Exécuter l'instance?? pour afficher l'instance en ligne