views:

150

answers:

2

Hi

Perhaps this is a bug, but I cannot access an outer document from an iframe with jquery (IE7).

here a very simple example:

top document:

<html>
<head>
</head>
<body>
<iframe src="test2.html" id="UserIFrame" name="UserIFrame">
</body>
</html>

and child iframe:

<html>
<head>
<script type="text/javascript" src="styles/genevadesign_jquery-1.4.1.js"></script>
<script type="text/javascript">
       function doit(){
          $('body',top.document).append($('#test'));
          $('#test',top.document).fadeIn(300);
      }
</script>
</head>
<body>
<div id="test">test</div>
<input type="button" onclick="doit();"/>
</body>
</html>

As you can see, I try to access the top document from the inner frame like this:

$('body', top.document).append($('#test'));

But this does not work in IE7 "Invalid Argument". It works within the same document, but as soon as I refer another document it stops working.

PS. Gecko Browser can handle this. Just IE7 so far is not able to do so.

A: 

tries with "window.parent"

andres descalzo
Yes, now I get no more errors but the <div> I wish to copy is still not in the outer frame.
katamshut
A: 

thanks andres for your suggestion but..

 $('body',window.parent).append($('#test'));

this way it works nowhere. even in gecko browsers such as firefox are not able to append any stuff. I also tried

$('body',window.parent.document).append($('#test'));

but this again turned me into the IE Problem I described on top.

Is this simply not possible?

regards

katamshut