Detect when an iframe starts to load new URL

前端 未结 4 1950
孤街浪徒
孤街浪徒 2021-01-31 02:07

How can I detect that an iframe on my page starts to load a new page?

Our situation is:

  • When iFrame content starts to change we need to di
4条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-01-31 02:46

    There is already a possible solution at: iFrame src change event detection?

    However, if you want to manipulate the target page, then it is not needed to touch the iframe-target file content. Just add the correct JS code in parent page and it can access SAME-ORIGIN iframe. I used something like this: