How to access parent Iframe from JavaScript

后端 未结 9 1533
梦毁少年i
梦毁少年i 2020-11-22 07:50

Well, I have an IFrame, which calls a same domain page. My problem is that I want to access some information from this parent Iframe from this called page (from JavaScript).

9条回答
  •  一个人的身影
    2020-11-22 08:45

    Try this, in your parent frame set up you IFRAMEs like this:

    
    
    
    

    Note that the id of each frame is passed as an anchor in the src.

    then in your inner html you can access the id of the frame it is loaded in via location.hash:

    
    

    then you can access parent.document.getElementById() to access the iframe tag from inside the iframe

提交回复
热议问题