views:

18

answers:

2

Inside http://mydomain1.com/index.html

<html>
<body>
<script type="text/javascript">
  var a = 1;
</script>
<iframe src="http://domain2.com/test2.html"&gt;&lt;/iframe&gt;
</body>
</html>

Inside http://domain2.com/test2.html

<script type="text/javascript">
  alert(parent.a); // forbidden
</script>

Any work arounds?

A: 

from the iframe you can access parent DOM nodes, but you cannot do that to parent window variables.

Tomasz Kowalczyk
no, not even nodes, coz the iframe is on a different domain. No work arounds at all ?
Shawn
+2  A: 

If you need to communicate with the other frame, you could use postMessage. This is only available on modern browsers (IE8, FF3, Opera 9, Chrome).

You cannot really have full access to cross domain frames due to the security reasons (Same Origin Policy).

Lekensteyn