views:

293

answers:

1

Okay, I've been searching for this for way too long already... I'm trying to find out how I can return the filename of the page that's running an included javascript, from inside that javascript.

I can easily do this in PHP using $_SERVER['SCRIPT_FILENAME'], but in Javascript this seems to be a lot harder.

Do I really need to substring it from location.href or is there a more efficient way?

A: 
var url=location.href;
return url.substring(url.lastIndexOf('/')+1)
kennebec