I'm trying to get the path of the js file to realize the version number. There's a way to do that?
Asked
Active
Viewed 86 times
0
-
1and where?? in HTML file, add more details – Girish Jun 10 '15 at 11:04
-
possible duplicate of [How to get the absolute path of the current javascript file name](http://stackoverflow.com/questions/13261970/how-to-get-the-absolute-path-of-the-current-javascript-file-name) – Thilo Jun 10 '15 at 11:06
-
Do you have a example or something for us to work with that will enable us to help you / answer your question? With no example = no solid answer. – NewToJS Jun 10 '15 at 11:06
-
Thanks everyone. Can't get the script from the html. We use a generic url (.../getJs) which redirects to different js files, according to different statuses. I'm trying to dynamically understand which js file I was redirected to. – Tomer Levi Jun 10 '15 at 14:54
1 Answers
0
You can add class or id to the <script>
tag and retrieve its src
attribute.
<script id="script" src="path/to/file.js">
<script>
document.getElementById('script').src
</script>

Waqas Ibrahim
- 153
- 11
-
This isn't worth posts as an answer without explaining how you would get the src attribute from a class name. Why not an ID? And what's wrong with `getElementsByTagName('script');` ... – NewToJS Jun 10 '15 at 11:11
-
I was just going to edit it to id or class :) and of course you can use any way to query DOM. – Waqas Ibrahim Jun 10 '15 at 11:12
-
-
Thanks everyone. Can't get the script from the html. We use a generic url (.../getJs) which redirects to different js files, according to different statuses. I'm trying to dynamically understand which js file I was redirected to. – Tomer Levi Jun 10 '15 at 14:53