Track only iframe history

后端 未结 6 714
囚心锁ツ
囚心锁ツ 2021-01-13 06:06

I have a page which contains an iframe and I want to track the history of the iframe only. I tried to use the history object like this:



        
6条回答
  •  感动是毒
    2021-01-13 06:45

    There is an easy way to do this, provided of course that the iframe content is the same domain.

    From the parent you bind to the beforeUnload or the load event of the iframe's window object. In the event's callback handler you simply do something along the lines of locations.push(getElementById("iframe").contentWindow.location.href) where locations is of course a previously defined array in the parent scope.

提交回复
热议问题