Anchor protocol attribute
Definition and usage
protocol
Attribute setting or return href attribute value The protocol part.
A protocol is a standard that specifies the way data is transmitted between computers.
See also:
JavaScript Reference Manual:location.protocol attribute
Example
Example 1
Return the link protocol:
var x = document.getElementById("myAnchor").protocol;
Example 2
Change the link protocol:
document.getElementById("myAnchor").protocol = "mailto:";
Syntax
Return the protocol attribute:
anchorObject.protocol
Set the protocol attribute:
anchorObject.protocol = protocol
Attribute value
Value | Description |
---|---|
protocol |
Specifies the protocol of the URL. Possible values:
And so on... |
Technical Details
Return Value: | A string value representing the protocol part of the URL, including the colon (:]. |
---|
Browser Support
Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|
Chrome | Edge | Firefox | Safari | Opera |
Support | Support | Support | Support | Support |