js function to get filename from url

var filename = url.split('/').pop()

Why so difficult?

var filename = url.split('/').pop().split('#')[0].split('?')[0];


Use the match function.

function GetFilename(url)
{
   if (url)
   {
      var m = url.toString().match(/.*\/(.+?)\./);
      if (m && m.length > 1)
      {
         return m[1];
      }
   }
   return "";
}