X
HOME HTML5 CSS3 JAVASCRIPT SQL PHP5 JQUERY ANGULAR BOOTSTRAP3 XML MORE...
REFERENCES | EXAMPLES | FORUM | ABOUT

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

Your suggestion:

Close [X]

Thank You For Helping Us!

Your message has been sent to W3Schools.

Close [X]
Search w3schools.com:

WEB HOSTING

UK Reseller Hosting

WEB BUILDING

Download XML Editor FREE Website BUILDER Free HTML5 Templates

SHARE THIS PAGE

facebook