Location protocol Property
Location object
Definition and Usage
The protocol property sets or returns the protocol of the current URL, including the colon : part.
The 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
The protocol can be set to:
| Parameters |
| protocol |
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 »
Location object