get file name in url code example Example: get filename from url js var filename = location.pathname.substr(location.pathname.lastIndexOf("/")+1);