let url = window.location.pathname; let filename = url.substring(url.lastIndexOf('/')+1); console.log("filename",filename); alert(filename);