Je souhaite en savoir plus sur les règles d'origine identique. Il y a un site qui en parle. Mais il doit y avoir sth. mal avec le premier exemple parce que je suis une erreur Illegal document.domain value
Erreur de règle d'origine identique
Voici le code problématique:
Le site parent situé à http://www.qnimate.com/parent.html:
<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>
et iframe situé à http://www.blog.qnimate.com/child.html:
<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>
Ok donc l'exemple ci-dessus n'est pas correct? – Mulligun81
@ Mulligun81 - Oui. L'exemple de code que vous avez observé génère une erreur incorrecte. – Quentin