Tutorialspoint

HTML DOM Anchor pathname Property

<!DOCTYPE html>
<html>
   <body>
      <h1>Company</h1>
      <p><a id="mylink" hreflang="en" href="https://abc.com/abc.html/#new">Products</a></p>
      <h2 id="myid"></h2>
      <button onclick="display1()">Display pathname</button>
      <button onclick="display2()">Display hreflang</button>
      <script>
         function display1() {
            var a = document.getElementById("mylink").pathname;
            document.getElementById("myid").innerHTML = a;
         }
         function display2() {
            var a = document.getElementById("mylink").hreflang;
            document.getElementById("myid").innerHTML = a;
         }
      </script>
   </body>
</html>

Advertisements
Loading...

We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy.