0
HTML body의 id = "review"태그에 iframe의 내용 (예제 페이지로 google 사용)을 채우려고합니다. iframe의 내용 대신 [object HTMLDocument]를 반환합니다. 내가 도대체 뭘 잘못하고있는 겁니까?div의 iframe 내용 출력 내용
function googleReview()
{
var iframeWindow = document.getElementById('google_window').contentDocument;
document.getElementById("review").innerHTML=iframeWindow;
}
</script>
</head>
<body>
<iframe width="300px" height="80px" frameborder="0" scrolling="yes" name="google_window" id="google_window" src="http://google.com"></iframe>
<p id="review">Review Area</p>
<button type="button" onclick="googleReview()">Change Review</button>
iframe이 동일한 도메인에 있지 않으면 콘텐츠에 액세스 할 수 없을 것이라고 생각합니다. –
는 'iframeWindow.body.innerHTML'을 시도 했습니까? iframeDocument라는 변수의 이름은 iframe의 window.document를 가져오고 창 자체는 가져 오지 않아야합니다. – skarmats
@Matt - 같은 도메인에서 할 때 "undefined"를 반환하므로 잘못 처리해야합니다. 이 유형의 사례에 교차 도메인 제한이 있다는 것이 맞다고 생각합니다. – JMC