Closed Bug 733777 Opened 12 years ago Closed 12 years ago

Changing style from onmouseover does not work

Categories

(Firefox :: Untriaged, defect)

10 Branch
x86
Windows 7
defect
Not set
normal

Tracking

()

RESOLVED INVALID

People

(Reporter: bugreport, Unassigned)

Details

Attachments

(1 file)

User Agent: Mozilla/5.0 (Windows NT 6.1) AppleWebKit/535.11 (KHTML, like Gecko) Chrome/17.0.963.66 Safari/535.11

Steps to reproduce:

I clicked the text in de div below (Firefox 10.0.2)

<!doctype html>

<html>
  <head>
    <title>Style test</title>
    <meta charset="utf-8" />

    <script type="text/javascript">

    	document.addEventListener("DOMContentLoaded", init, false);

    	function init() 
	{
    		var info = document.getElementById("info");
    		info.addEventListener("mousedown", changeColor, false);
		info.style.color= 'green';
    	}

    	function changeColor(event) 
	{
		info.style.color= 'red';
    	}

    </script>

  </head>

  <body>
	<div id="info">Click me to make me red!</div>
  </body>
</html> 


Actual results:

The text stayed green.


Expected results:

The text should have turned red when clicked, as in all other browsers.
Attached file Reporter's test case
Error in code

From error console:

Timestamp: 3/7/2012 2:26:38 PM
Error: info is not defined
Source File: file:///C:/Documents%20and%20Settings/Tim%20Cormier/Desktop/test.html
Line: 21
Shouldn't have used the var keyword before info (I was probably a bit sleepy). So Firefox is the only browser that handles it correctly, all other browsers incorrectly saw info as global variable.
Status: UNCONFIRMED → RESOLVED
Closed: 12 years ago
Resolution: --- → INVALID
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: