Last active
June 21, 2018 17:24
-
-
Save umidjons/5974534 to your computer and use it in GitHub Desktop.
Get current URL/path in javascript (without domain)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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/' | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I wanna code!!!!!