Getting global Javascrip variable in another Javascrip file
Lets say I have a variable:
<script type="text/javascript">
var myVariable = "something";
</script>
After this js global variable declaration I have another javascript:
<script type="text/javascript" src="myScriptFile.js"></script>
In this file I need to use the value of my global myVariable variable. I
know that I can do it by setting this value in some HTML, then using DOM
or jQuery or something else get this value in the file, but I want to
avoid creating those kind of hidden fields in my HTML. Is there any better
way to do this?
No comments:
Post a Comment