Location pathnameProperty

Location 对象参考手册Location Object

Definition and Usage

The pathname property is a readable and writable string that can set or return the path part of the current URL.

Syntax

location.pathname


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the pathname property.


Example

Example

Return the pathname of the current URL:

<script>

document.write(location.pathname);

</script>

Output of the above example:


Try it Yourself »


Location 对象参考手册Location Object Other Extensions