Latest web development tutorials

Location href attribute

Location Object Reference Location Object

Definition and Usage

href attribute is a readable and writable string sets or returns the complete URL of the document currently displayed.

grammar

location.href


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support href attribute


Examples

Examples

Returns the full URL (this page):

<script>

document.write(location.href);

</script>

Examples of the above output:


try it"


Location Object Reference Location Object