0

Update: This problem seems to have disappeared in Chrome 33.

Can properties of the window object (name, screen in the example below) be used as JavaScript variables? In FireFox it works as expected but not so in Chrome. Why?

html:

<input type="button" id="name" value="name before">
<input type="button" id="screen" value="screen before">

js:

var name = document.getElementById('name');
var screen = document.getElementById('screen');

console.log(name);
console.log(screen);

name.addEventListener('click', function ()
{
    name.value = "after";
});

screen.addEventListener('click', function ()
{
    screen.value = "after";
});
  • possible duplicate of [What should every JavaScript programmer know?](http://stackoverflow.com/questions/2628672/what-should-every-javascript-programmer-know) – Barmar Feb 11 '14 at 10:22
  • Where are you accessing `window` properties? – Barmar Feb 11 '14 at 10:24
  • duplicate of this? http://stackoverflow.com/questions/15968224/addeventlistener-not-working-in-chrome – alfonsob Feb 11 '14 at 10:34
  • @Barmar: name and screen are both properties of the window object. I guess window.name and my variable name collide. Firefox take one path, Chrome the other. – klutsteine Feb 11 '14 at 11:18

0 Answers0