Closed Bug 290791 Opened 20 years ago Closed 20 years ago

Incorrect JavaScript global variables handling in any script

Categories

(Toolkit Graveyard :: Error Console, defect)

x86
Windows XP
defect
Not set
critical

Tracking

(Not tracked)

VERIFIED DUPLICATE of bug 114461

People

(Reporter: akattan, Assigned: bugs)

Details

Attachments

(1 file)

User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.1; rv:1.7.3) Gecko/20041001 Firefox/0.10.1
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; rv:1.7.3) Gecko/20041001 Firefox/0.10.1

Please try the page below, the global variables will never print out correctly.
I teach javascript for 3 years now (my other email is akattan@hu.edu.jo).
<html>
<head>
  <title>Global Variables in JS</title>
  <script type="text/javascript">
  <!--
   var x = 10, y = 2.13 , str = "anything";

   function printGlobal() {
     document.writeln(x);         //Only this variable will be printed
     document.writeln(y);         //this will not print ?!
     document.writeln(str);       //this will not print ?!
   }

   function printLocal() {
   var x = 5, y = 1.25 , str = "something";
     document.writeln(x);
     document.writeln(y);
     document.writeln(str);
     document.writeln("Global x is "+this.x); //this will not print ?!
   }
       //-->
</script>
</head>
<body>
  <p>Click to start</p>
  <form>
     <input type="button" value="print Globals" onclick="printGlobal()"/> &nbsp;
&nbsp;
     <input type="button" value="print Locals" onclick="printLocal()"/>
  </form>
</body>
</html>


Reproducible: Always

Steps to Reproduce:
Any Global variable will lose its setting for some reason
Please check the program above
Actual Results:  
Incorrect results each time for every global variable in JavaScript when using any 
event like onclick, onmouseover, etc.

Expected Results:  
Run the script I gave above in any other browser and see the difference...

I'm an assigned lecturer at the IT College/ Hashemite University / Jordan
I teach web programming and Java. I like your browser and I would love to help
make it better. 
Please check this problem
See the same in a current nightly  (Windows; U; Windows NT 5.1; en-US; rv:1.8b2)
Gecko/20050415 Firefox/1.0+

*** This bug has been marked as a duplicate of 114461 ***
Status: UNCONFIRMED → RESOLVED
Closed: 20 years ago
Resolution: --- → DUPLICATE
Java Script error with global variables
Status: RESOLVED → VERIFIED
Product: Firefox → Toolkit
Product: Toolkit → Toolkit Graveyard
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: