Track only iframe history

后端 未结 6 663
囚心锁ツ
囚心锁ツ 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:54

    It's unlikely you will be able to access any objects associated with the frame because of the same-origin policy.

    Have you tried setting the domains to be equal on the page itself and the iframe? e.g.

    //somewhere on your page in a script tag
    document.domain = "your-top-level-domain.com";
    

    this should signal to the browser that the pages trust each other and should be given access to their internal state

提交回复
热议问题