Window location.protocol

Example

Return the protocol of the current URL:

let protocol = location.protocol;
Try it Yourself »

Description

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.


Syntax

Return the protocol property:

location.protocol

Set the protocol property:

location.protocol = protocol

Property Value

Parameter Description
protocol The protocol of the URL. Examples:
  • file:
  • ftp:
  • http:
  • https:
  • mailto:

Return Value

Type Description
A stringThe protocol of the current URL, including the colon (:)

Browser Support

location.protocol is supported in all browsers:

Chrome Edge Firefox Safari Opera IE
Yes Yes Yes Yes Yes Yes


Copyright 1999-2023 by Refsnes Data. All Rights Reserved.