THE WORLD'S LARGEST WEB DEVELOPER SITE
HTMLCSSJAVASCRIPTSQLPHPBOOTSTRAPJQUERYANGULARXML
 

Location protocol Property

Location Object Reference Location Object

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:
  • file:
  • ftp:
  • http:
  • https:
  • mailto:
  • etc..

Technical Details

Return Value: A String, representing the protocol of the current URL, including the colon (:)

Location Object Reference Location Object