I don't understand why the below example doesn't work. I thought variables are global unless they are in a function:
test.html contains
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<HTML>
<BODY>
<script src="c:/tempcandelete/menutop.js"></script>
</BODY>
</HTML>
menutop.js contains
document.write('<scr'+'ipt language=javascript src="c:/tempcandelete/test2.js"><\/scr'+'ipt>');
if (blah == "blah"
{
alert ("blah"
}
else {
alert ("not blah"
};
test2.js contains
var blah = "bldah";
alert ("in test2"
;
When I try to render test.html, I get:
Error: blah is undefined
and then I get the alert "in test2"
Any way I can get this to work?
TIA
test.html contains
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<HTML>
<BODY>
<script src="c:/tempcandelete/menutop.js"></script>
</BODY>
</HTML>
menutop.js contains
document.write('<scr'+'ipt language=javascript src="c:/tempcandelete/test2.js"><\/scr'+'ipt>');
if (blah == "blah"
{
alert ("blah"
}
else {
alert ("not blah"
};
test2.js contains
var blah = "bldah";
alert ("in test2"
When I try to render test.html, I get:
Error: blah is undefined
and then I get the alert "in test2"
Any way I can get this to work?
TIA