Is x a reserved keyword in Javascript FF/Safari not in IE?

前端 未结 4 2057
鱼传尺愫
鱼传尺愫 2021-01-24 05:07

A web page of a web application was showing a strange error. I regressively removed all the HTML/CSS/JS code and arrived to the basic and simple code below.

<         


        
4条回答
  •  死守一世寂寞
    2021-01-24 05:42

    Your problem is with variable scope, not that "x" is reserved. An image object has a property named "x". You can see this with Chrome's developer tools. When you call "alert(x);" on the image object, the "x" in scope is the "x" property on the image.

提交回复
热议问题