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'

王林
Release: 2023-09-23 09:17:01
forward
2001 people have browsed it

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
Copy after login

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
Copy after login

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>
Copy after login

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 of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template