Location hrefProperty

Location 对象参考手册Location Object

Definition and Usage

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

Syntax

location.href


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the href property


Example

Example

Return the complete URL (current page):

<script>

document.write(location.href);

</script>

The output of the above example:


Try it yourself »


Location 对象参考手册Location Object Other Extensions