Changing style from onmouseover does not work

RESOLVED INVALID

Status

()

Firefox
Untriaged
RESOLVED INVALID
6 years ago
6 years ago

People

(Reporter: bugreport, Unassigned)

Tracking

10 Branch
x86
Windows 7
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(1 attachment)

(Reporter)

Description

6 years ago
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.

Comment 1

6 years ago
Created attachment 603875 [details]
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
(Reporter)

Comment 2

6 years ago
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
Last Resolved: 6 years ago
Resolution: --- → INVALID
You need to log in before you can comment on or make changes to this bug.