2012-09-25 5 views
1

Windows Metro Style App을 클릭하면 "다시로드"버튼을 클릭하고 iframe의 내용을 다시 불러오고 싶습니다. 버튼을 클릭하면 Javascript 런타임 오류가 발생하고 쓰기 권한이 없다고 표시됩니다. 다음Windows Metro Style App에서 iframe의 내용을 다시로드하는 방법

소스 코드 :

==의 default.html을 ==의

<iframe id="iframe" src="http://example.com" width="800px" height="400px"></iframe> 
<button id="reloadButton">Reload</button> 

== default.js ==

var reloadButton = document.getElementById("reloadButton"); 
reloadButton.addEventListener("click", reload, false); 

function reload() { 
    var iframe = document.getElementById("iframe"); 
    iframe.contentWindow.location.reload(); 
} 

어떤 도움을 받고있다.

덕분에,

답변

0

이 때문에 same origin policy의입니다. postMessage 그 프레임의 부모에게, 예를 들어, 당신이 할 수있는 프레임 내부 페이지의 URL을 업데이트

iframe.contentWindow.location.href = "http://www.example.com"` 

- 소스 코드에 액세스 할 수있는 경우 :

당신이 뭔가를 작성해야 페이지의

+0

조언 해 주셔서 감사합니다. postMessage를 사용하면 부모 윈도우의 버튼에서 iframe의 페이지를 새로 고칠 수 있습니다. Gist에 샘플 코드를 넣었습니다. https://gist.github.com/3792928 –

관련 문제