Latest web development tutorials

Location protocol property

Location Object Reference Location Object

Definition and Usage

protocol property is a readable and writable string sets or returns the URL of the current agreement.

grammar

location.protocol


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support protocol property


Examples

Examples

Returns the protocol part of the current URL:

<script>

document.write(location.protocol);

</script>

Examples of the above output:


try it"


Location Object Reference Location Object