Skip to content

Instantly share code, notes, and snippets.

@Sn0wCrack
Created November 15, 2013 08:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Sn0wCrack/7480792 to your computer and use it in GitHub Desktop.
Save Sn0wCrack/7480792 to your computer and use it in GitHub Desktop.
Grabs the name of the current document that the JavaScript file is running in.
function getFileName()
{
var url = document.location.href;
url = url.substring(0, (url.indexOf("#") == -1) ? url.length : url.indexOf("#"));
url = url.substring(0, (url.indexOf("?") == -1) ? url.length : url.indexOf("?"));
url = url.substring(url.lastIndexOf("/") + 1, url.length);
return url;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment