How to access parent Iframe from JavaScript

后端 未结 9 1391
梦毁少年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:38

    Once id of iframe is set, you can access iframe from inner document as shown below.

    var iframe = parent.document.getElementById(frameElement.id);
    

    Works well in IE, Chrome and FF.

提交回复
热议问题