JavaScript window.location.pathname

JavaScript window location pathname property enables you to get the current URL path excluding the domain name. JavaScript location pathname property returns URL path excluding protocol, domain/host name and querystirng variables. JavaScript location object belongs to JavaScript window object that allows you to access the pathname property using window.location.pathname. You can also access the pathname property directly as location.pathname.

Try the sample below to learn and practice the code functionality of JavaScript window location pathname property:


Edit this code and click update to view output