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

前端 未结 7 1275
故里飘歌
故里飘歌 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:

    <div id="num"></div>

    alert(num); //Element

    num = 3; //throws exception

    var num = 3; //ok

    0 讨论(0)
提交回复
热议问题