Home >Web Front-end >HTML Tutorial >The Chinese translation of HTML DOM Anchor protocol Property is 'HTML DOM anchor protocol property'

The Chinese translation of HTML DOM Anchor protocol Property is 'HTML DOM anchor protocol property'

王林
王林forward
2023-09-23 09:17:011917browse

HTML DOM Anchor protocol attribute is used to set or return the protocol linked in the href attribute.

The following is the syntax for setting the protocol attribute -

anchorObj.protocol = protocol_url

Above, protocol_url is the protocol of the URL. Values ​​can be http, https, ftp, etc.

The following is the syntax for returning protocol attributes-

anchorObj.protocol

Now let us look at an example of implementing the DOM Anchor protocol attribute-

Example

Live demonstration

<!DOCTYPE html>
<html>
<body>
<h1>Demo Heading</h1>
<p>Link = <a id="mylink" hreflang="en" href="https &minus;//abc.com &minus;6064/abc.html/#new">Services</a></p>
<h2 id="myid"></h2>
<button onclick="display1()">Display pathname</button>
<button onclick="display2()">Display hreflang</button>
<button onclick="display3()">Display port</button>
<button onclick="display4()">Display protocol</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;
   }
   function display3() {
      var a = document.getElementById("mylink").port;
      document.getElementById("myid").innerHTML = a;
   }
   function display4() {
      var a = document.getElementById("mylink").protocol;
      document.getElementById("myid").innerHTML = a;
   }
</script>
</body>
</html>

Output

HTML DOM Anchor protocol Property的中文翻译是"HTML DOM 锚点协议属性"

Click the "Show Protocol" button -

The Chinese translation of HTML DOM Anchor protocol Property is 'HTML DOM anchor protocol property'

The above is the detailed content of The Chinese translation of HTML DOM Anchor protocol Property is 'HTML DOM anchor protocol property'. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:tutorialspoint.com. If there is any infringement, please contact admin@php.cn delete