0
同じ起源のポリシーについて知りたいです。それについて話しているsiteがあります。しかし、sthする必要があります。同じ起点のポリシーエラー
http://www.qnimate.com/parent.htmlにある親サイト:私はここでエラーにIllegal document.domain value
を得たので最初の例と間違っ問題のあるコードがある
<iframe src="http://www.blog.qnimate.com/child.html" id="myIFrame"></iframe>
<script>
window.document.domain = "www.qnimate.com";//you also need to set the parent's document.domain variable
window.document.getElementById("myIFrame").contentWindow.document.body.style.backgroundColor = "red";//this access is allowed by default
</script>
とhttp://www.blog.qnimate.com/child.htmlに位置IFRAME:
<script>
window.document.domain = "www.qnimate.com"; //if we remove this line then the below line will not work and throw a same origin policy exception.
window.parent.document.body.style.backgroundColor = "blue";
</script>
上記の例は正しくありませんか? – Mulligun81
@ Mulligun81 - はい。あなたが観察したサンプルコードは、エラーをスローします。 – Quentin