Difference between [removed].href and top.location.href

后端 未结 4 1946
轮回少年
轮回少年 2020-11-27 11:34

Can Anyone tell me the difference between window.location.href and top.location.href ?

And also where to use which one.

And which

4条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-11-27 11:50

    top refers to the window object which contains all the current frames ( father of the rest of the windows ). window is the current window.

    http://www.howtocreate.co.uk/tutorials/javascript/browserinspecific

    so top.location.href can contain the "master" page link containing all the frames, while window.location.href just contains the "current" page link.

提交回复
热议问题