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

前端 未结 4 2053
鱼传尺愫
鱼传尺愫 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:51

    I can't seem to find any documentation to support this, but my guess is that the tag is being treated specially, and the object is actually a JavaScript Image object, not a normal DOM element. The Image object has an x property, and so your unscoped reference to x means Image.x. If you want the global x property, just use window.x instead.

提交回复
热议问题