- Nov 28, 2000
- 2,224
- 0
- 0
I have a question that Ive been googling for an hour now with no results!
Hopefully someone here can help.
I want to know, if I include a JS file in a html page, does it have access to global variables in the html page it was called from??
ex:
<html>
..
.
var test = "GLOBAL?";
<script language="JavaScript" src="test.js" type="text/javascript"></script>
..
..
</html>
Is it possible to have that variable global for both scripts?
Im dealing with ASP.net and i have to inject javascript into the page to set a variable...
Problem is my code to inject is in a usercontrol, when is inside the content placer of a master page. So, for some dumb reason it never gets executed.
Now im trying to add the var through the header (it adds it right after the header) and the variable gets declared fine, now I just have to find a way to get it to my external JS file....
Ideas?
Thanks in advance!
P.S. Yes, I know im crazy and this is getting complicated for nothing probably....
Hopefully someone here can help.
I want to know, if I include a JS file in a html page, does it have access to global variables in the html page it was called from??
ex:
<html>
..
.
var test = "GLOBAL?";
<script language="JavaScript" src="test.js" type="text/javascript"></script>
..
..
</html>
Is it possible to have that variable global for both scripts?
Im dealing with ASP.net and i have to inject javascript into the page to set a variable...
Problem is my code to inject is in a usercontrol, when is inside the content placer of a master page. So, for some dumb reason it never gets executed.
Now im trying to add the var through the header (it adds it right after the header) and the variable gets declared fine, now I just have to find a way to get it to my external JS file....
Ideas?
Thanks in advance!
P.S. Yes, I know im crazy and this is getting complicated for nothing probably....