Window location.protocol attribute

Definition and usage

protocol Sets or returns the protocol of the current URL, including the colon (:].

This protocol is a standard used to specify the way data is transmitted between computers.

Example

Return the protocol of the current URL:

let protocol = location.protocol;

Try it yourself

Syntax

Return the protocol attribute:

location.protocol

Set the protocol attribute:

location.protocol = protocol

Attribute value

Value Description
protocol The protocol of the URL. For example:

Return value

Type Description
String The protocol of the current URL, including the colon (:].

Browser Support

All Browsers Support location.protocol:

Chrome IE Edge Firefox Safari Opera
Chrome IE Edge Firefox Safari Opera
Support Support Support Support Support Support