Skip to content

Instantly share code, notes, and snippets.

@umidjons
Last active June 21, 2018 17:24
Show Gist options
  • Save umidjons/5974534 to your computer and use it in GitHub Desktop.
Save umidjons/5974534 to your computer and use it in GitHub Desktop.
Get current URL/path in javascript (without domain)
jQuery(document).ready(function(){
var path = window.location.pathname;
var pathName = path.substring(0, path.lastIndexOf('/') + 1);
console.log(path); // get current path, for ex: '/index.php', '/docs/pdf/detail.php'
console.log(pathName); // for ex: '/index.php'=>'/', '/docs/pdf/detail.php'=>'/docs/pdf/'
});
@fhcuieas
Copy link

What is this?

@fhcuieas
Copy link

I wanna code!!!!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment