Get the file name of the page


/ Published in: JavaScript
Save to your folder(s)



Copy this code and paste it in your HTML
  1. function getFileName() {
  2. var url = document.location.href;
  3. url = url.substring(0, (url.indexOf("#") == -1) ? url.length : url.indexOf("#"));
  4. url = url.substring(0, (url.indexOf("?") == -1) ? url.length : url.indexOf("?"));
  5. url = url.substring(url.lastIndexOf("/") + 1, url.length);
  6. return url;
  7. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.