Scroll to top of parent frame on iframe change?

前端 未结 3 1678
醉酒成梦
醉酒成梦 2021-02-05 14:14

Is it possible to scroll(0,0) to the top of the parent page when the user browses in an iframe? For example, we have an iframe that is the entire height of the page with search

3条回答
  •  深忆病人
    2021-02-05 14:26

    As an alternative, you can have the iframe ask the parent frame to scroll to the top with

    parent.scrollTo(0,0);
    

    I haven't researched the official browser support for it, but it works in IE9, FF10, Chrome 17 and Safari 5.1.

提交回复
热议问题