KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
When running the following block of code, FF and Chrome output typeof(hiya) = string while IE7/8 output typeof(hiya) = undefined . <html> <body> <script type="text/javascript"> window.hiya = 'hiya'; </script> <script type="text/javascript"> if( false ) { var hiya = 1; } document.write( "typeof(hiya) = "+ typeof(hiya) ); </script> </body> </html> Each of the following makes the problem go away: Combining everything into a single <script> block. Removing the if block. Renaming var hiya = 1 to var hiya2 = 1 . Renaming var hiya = 1 to window.hiya = 1 . Renaming var hiya = 1 to hiya = 1 . What is happening? Is there a scoping bug in IE?
Tags (comma-separated)
Save Edits
Cancel