Can I get the current .php or .html file name by JavaScript? The script is in the external file in respect to current .php or .html, so need the name file name of this current .html of .php:
<!DOCTYPE html>
<html>
<head>
...
<script src="js/Script.js" type="text/javascript"></script>
</head>
<body>
...
</body>
</html>
I tried this but the variable value was empty, maybe because currently I use the local host. Anything that can to do which will be work on both local and remote host?
window.locationmay help but depends on your routing algo. for. eg if you run in this page you will actually not get php or html because the uri routing will not show itwindow.location.pathnameas ur accepted answer.