Results 1 to 3 of 3
May 23, 2008, 21:20 #1
- Join Date
- Sep 2005
- 0 Post(s)
- 0 Thread(s)
How can I use JS script to change other scripts' variables?
Suppose that I have the following JS scripts inside the <body> tag:
magicVar = "whatever";
someVar = "whatever";
Is there anyway I can change the value of magicVar in the first JS script from inside the <head> tag of the same HTML document?
In other words:
I want to have a JS script in the <head> of an HTML document that scans through all the <script> tags inside the <body> tag of the same HTML document, and if it finds a variable named "magicVar" inside any of the <body>'s <script> tags it'll change it's/their value to a new one. Can I use DOM or anything else to achieve this?
I don't want to change the value of the variable magicVar, I want to change the value that will be assigned to the variable magicVar. I know I can change it manually but this is not what I need to do.
I want to apply this to a more complicated situation.