Location protocolProperty
Location Object
Definition and Usage
The protocol property can be used to set or return the protocol of the current URL, including the colon:part.
URL protocol is a standard that specifies how data is transmitted between computers.
Syntax
Return the protocol property:
location.protocol
Set the protocol property:
location.protocol = protocol
protocol can be set to:
| Parameter | Description |
| protocol |
URL protocol, can be:
|
Browser Support
All browsers support the protocol property
| Chrome | Edge | Firefox | Safari | Opera | IE |
| Supported | Supported | Supported | Supported | Supported | Supported |
Example
Example
Return the protocol part of the current URL:
document.write(location.protocol);
The output of the above example is:
Try it yourself »
Location Object Other extensions