Example
Return the protocol of the current URL:
var x = location.protocol;
The result of x will be:
Try it Yourself »
Definition and Usage
The protocol property sets or returns the protocol of the current URL, including the colon (:).
The protocol is a standard that specifies how data are transmitted between computers.
Browser Support
Property | |||||
---|---|---|---|---|---|
protocol | Yes | Yes | Yes | Yes | Yes |
Syntax
Return the protocol property:
location.protocol
Set the protocol property:
location.protocol=protocol
Property Values
Value | Type | Description |
---|---|---|
protocol | String |
The protocol of the URL. Possible values:
|
Technical Details
Return Value: | A String, representing the protocol of the current URL, including the colon (:) |
---|
< Location Object