2016-09-02 2 views
1

내에 위치한 요소에 의해 부모 iframe 요소를 가져옵니다 :다음과 같은 HTML을 가정 iframe이

<div> 
    <iframe src=".."> 
     <!-- The following would be the content of the iframe --> 
     <html><head></head><body> 
      <span>I'm the node</span> 
     </body></html> 
    </iframe> 
</div> 

그리고 당신은 변수 iframeNode가 iframe을 내 <span> 요소를 포함해야합니다. 스크립트 컨텍스트가 부모 창입니다.

상위 iframe 요소 얻을 것입니다 방법 :이 노드에 의해

<iframe src="..."></iframe> 

를? 이론적으로

는 :

var iframe = iframeNode.myParentIframeElementInTheParentScope; 

답변

1

iframe에 대한 유일한 참조

var iframe = iframeNode.ownerDocument.defaultView.frameElement;

가있는 iframe 요소를 참조합니다 다음, 그 iframe (= iframeNode)에서 span 경우 부모 창.

관련 문제