Return the protocol of a link:
The result of x will be:
The protocol property sets or returns the protocol part of the href attribute value.
The protocol is a standard that specifies how data are transmitted between computers.
The protocol property is supported in all major browsers.
Return the protocol property:
Set the protocol property:
Value | Description |
---|---|
protocol |
Specifies the protocol of a URL. Possible Values:
|
Return Value: | A String, representing the protocol part of the URL, including the colon sign (:) |
---|
Change the protocol of a link:
JavaScript reference: location.protocol Property