Latest web development tutorials

Location pathname property

Location Object Reference Location Object

Definition and Usage

pathname attribute is a readable and writable string sets or returns the path portion of the current URL.

grammar

location.pathname


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support pathname property


Examples

Examples

Returns the name of the current path of the URL:

<script>

document.write(location.pathname);

</script>

Examples of the above output:


try it"


Location Object Reference Location Object