
- HTML Tutorial
- HTML - Home
- HTML - Overview
- HTML - Basic Tags
- HTML - Elements
- HTML - Attributes
- HTML - Formatting
- HTML - Phrase Tags
- HTML - Meta Tags
- HTML - Comments
- HTML - Images
- HTML - Tables
- HTML - Lists
- HTML - Text Links
- HTML - Image Links
- HTML - Email Links
- HTML - Frames
- HTML - Iframes
- HTML - Blocks
- HTML - Backgrounds
- HTML - Colors
- HTML - Fonts
- HTML - Forms
- HTML - Embed Multimedia
- HTML - Marquees
- HTML - Header
- HTML - Style Sheet
- HTML - Javascript
- HTML - Layouts
- HTML References
- HTML - Tags Reference
- HTML - Attributes Reference
- HTML - Events Reference
- HTML - Fonts Reference
- HTML - ASCII Codes
- ASCII Table Lookup
- HTML - Color Names
- HTML - Entities
- HTML - Fonts Ref
- HTML - Events Ref
- MIME Media Types
- HTML - URL Encoding
- Language ISO Codes
- HTML - Character Encodings
- HTML - Deprecated Tags
HTML DOM Anchor protocol Property
The HTML DOM Anchor protocol property is used to set or return the protocol of a link in the href attribute.
Following is the syntax to set the protocol property −
anchorObj.protocol = protocol_url
Above, protocol_url is the protocol of the URL. The values can be http, https, ftp, etc.
Following is the syntax to return the protocol property −
anchorObj.protocol
Let us now see an example to implement the DOM Anchor protocol property −
Example
<!DOCTYPE html> <html> <body> <h1>Demo Heading</h1> <p>Link = <a id="mylink" hreflang="en" href="https −//abc.com −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
Click on the “Display Protocol” button −
- Related Articles
- HTML DOM Anchor hostname Property
- HTML DOM Anchor password Property
- HTML DOM Anchor pathname Property
- HTML DOM Anchor href Property
- HTML DOM Anchor origin Property
- HTML DOM Anchor port Property
- HTML DOM Anchor hreflang Property
- HTML DOM Anchor download Property
- HTML DOM Anchor hash Property
- HTML DOM Anchor rel Property
- HTML DOM Anchor search Property
- HTML DOM Anchor target Property
- HTML DOM Anchor text Property
- HTML DOM Anchor type Property
- HTML DOM Anchor username Property

Advertisements