Location.pathname
JavaScript 1.0+, JScript 1.0+ Nav2+, IE 3+, Opera3+ Syntax
location.pathname
Description
The pathname property of the Location object represents the pathname portion of the URL.
In the following fictitious Web address:
http://www.mcp.com:80/foo?something#foobar
the pathname value would be the /foo portion.
Example
Listing 7.384 shows an example of how to get the pathname.
Listing 7.384 Example of the pathname Property
<html> <head> <title> Using the pathname property of the Location object</title> </head> <body> <script language="JavaScript"> <!-- Hide // function to display the pathname value function show(){ document.form1.text1.value=document.location.pathname; } // End Hide ---> </script> <form name="form1"> ... |
Get Pure JavaScript now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.