I'm trying to access javascript variables And it works this way:
//chart.html
<html lang="en-US">
<head>
<title>Test document</title>
<script>
var testVar2 = true;
</script>
<script type="text/javascript"
src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
</head>
<body id="mainPage">
</body>
</html>
Where I am able to call 'window.testVar2' //returns true
but if i switch it where there is a script include BEFORE the variable
declaration it returns 'undefined'
<html lang="en-US">
<head>
<title>Test document</title>
<script type="text/javascript"
src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
</head>
<body id="mainPage">
///////////////////////moved here
<script>
var testVar2 = true;
</script>
</body>
</html>
What am I doing wrong?
--
Job Board: http://jobs.nodejs.org/
Posting guidelines:
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en