Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

Location protocol Property

Location protocol Property

Location Object Reference 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
  • file:
  • ftp:
  • http:
  • https:
  • mailto:
  • |

    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 Reference Location object