X
HOME HTML CSS JAVASCRIPT SQL PHP JQUERY ANGULAR BOOTSTRAP XML ASP.NET 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

Internet Explorer Firefox Opera Google Chrome Safari

The protocol property is supported in all major browsers.


Syntax

Return the protocol property:

location.protocol

Set the protocol property:

location.protocol=protocol

Value Type Description
protocol String The protocol of the URL. Possible values:
  • file:
  • ftp:
  • http:
  • https:
  • mailto:
  • etc..

Return Value

Type Description
String 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