Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
148
rated 0 times [  150] [ 2]  / answers: 1 / hits: 16957  / 15 Years ago, fri, june 19, 2009, 12:00:00

In my HTML file I have linked to the JS with:



src=myscript.js?config=true


Can my JS directly read the value of this var like this?



alert (config);


This does not work, and the FireFox Error Console says config is not defined. How do I read the vars passed via the src attribute in the JS file? Is it this simple?


More From » html

 Answers
97
<script>
var config=true;
</script>
<script src=myscript.js></script>


You can't pass variables to JS the way you tried. SCRIPT tag does not create a Window object (which has a query string), and it is not server side code.


[#99282] Monday, June 15, 2009, 15 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
felixa

Total Points: 180
Total Questions: 113
Total Answers: 108

Location: Palau
Member since Sat, Aug 21, 2021
3 Years ago
;