get filenem js 1

get filenem js

var url = window.location.pathname;
var filename = url.substring(url.lastIndexOf('/')+1);
alert(filename);

Here is what the above code is Doing:
1. It’s getting the current URL of the page.
2. It’s getting the filename from the URL.
3. It’s alerting the filename.

Similar Posts