I want to display, with javascript, just the filename of the page the user is on. For example,
https://test.example.com/wow.html
should return
wow
I was trying to use the replace()
method, like so:
var url = document.URL;
document.getElementById("code").innerHTML = url.replace("http://test.example.com/", " ");
But I can't figure out how to remove the .html extension as well, or also replace https urls. Is there a better way to do this?
Thanks.