attribut javascript href


  Résultats de traduction:

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

attribut javascript hrefsyntaxe

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

Syntaxe : anchorObject.href=URL

attribut javascript hrefexemple

<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://www.php.cn">访问 php中文网</a>
<input type="button" onclick="changeLink()" value="改变链接">
<p>在本例中,我们改变超链接的文本和 URL。我们也改变 target 属性。target 属性的默认设置是 "_self",这意味着会在相同的窗口中打开链接。通过把 target 属性设置为 "_blank",链接将在新窗口中打开。</p>
</body>

</html>

Exécuter l'instance »

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

Recommandations populaires

Maison

vidéos

Questions et réponses