Created
February 16, 2011 20:15
-
-
Save bmavity/830089 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Sample Page for Module Intro</title> | |
</head> | |
<body> | |
<h1>Variables added to window object</h1> | |
<script src="samplePageExternal.js"></script> | |
<script> | |
// For IE. You've brought the alert punishment on yourself. ;) | |
if(!window.console) { | |
window.console = alert; | |
} | |
// This is defined in the external JavaScript file | |
// outside of a function, and with the var keyword. | |
console.log(window.outsideFunctionWithVar); // 2 | |
// This is defined in the external JavaScript file | |
// inside of a function, but without the var keyword. | |
console.log(window.insideFunctionWithoutVar); // 'hippo' | |
// This is defined in the external JavaScript file | |
// inside a function, and with the var keyword. | |
console.log(window.insideFunctionWithVar); // undefined | |
var thisPage = 'on it'; | |
// Defined above | |
console.log(window.thisPage); // 'on it' | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment