Getting parts of a URL with JavaScript

javascript, jquery

Solution

Try this :)

console.log(window.location.href.split('/').pop())

Problem

I'm currently on `www.google.com/folder/folder/archive.php` and using `window.location` to determine that. I actually want to target `/archive.php`, and nothing else. Is there something that could achieve that? ``` window.location.host = "www.google.com" window.location.pathname = "folder/folder/archive.php" ???? = "/archive.php ```

Original source

Related problems