2014-02-13 6 views
0

자바 스크립트에서 문서와 <head><body>이있는 iframe 요소를 만들고 싶습니다.자바 스크립트에서 문서로 iframe을 만드는 방법은 무엇입니까?

iframe은 dom에 존재할 수 없습니다.이 부분은 중요합니다.

var frame = $('<iframe />'); // [<iframe>​</iframe>​] 

var doc = document.implementation.createHTMLDocument() // #document 

// TypeError: Cannot read property 'ownerDocument' of null 
frame.append(doc); 

// HierarchyRequestError: Failed to execute 'appendChild' on 'Node': Nodes of type '#document' may not be inserted inside nodes of type 'IFRAME'. 
frame.get(0).appendChild(doc) 

나는 또한 그것을 복제하려고 한 후 DOM에를 생성하고했지만, 복제 된 iframe이 더 이상 문서를 포함

다음 시도는 작동하지 않습니다.

답변

0

사용하실 수 있습니까? iframe에 콘텐츠를 추가합니다.

frame.contents().find('html').html("content"); //content: content of your document 
관련 문제