Can I add attributes to 'window' object in javascript?

前端 未结 7 1276
故里飘歌
故里飘歌 2020-12-13 18:02

Can I add any random attribute to \'window\' object in javascript? Some thing like:

window.my_own_attr = \"my_value\"

Does it have any side

7条回答
  •  长情又很酷
    2020-12-13 18:32

    In IE if an element has an id, then that node is accessible on the window object as a property:

    alert(num); //Element

    num = 3; //throws exception

    var num = 3; //ok

提交回复
热议问题