1
 $('#iframe').ready(function() {
   $('#iframe a').attr('target', '_parent');
 });

simple as that.

EDIT:

my html:

 <div id='outerdiv'>
   <iframe src="http://localhost:8888/harvest/blog" id='iframe' scrolling=no></iframe>
 </div>
Daniel Node.js
  • 6,734
  • 9
  • 35
  • 57

3 Answers3

3

Have you tried using a .load() event instead? See the below question.

Javascript callback when IFRAME is finished loading?

Community
  • 1
  • 1
Munzilla
  • 3,805
  • 5
  • 31
  • 35
2

To access iframes you need to use 'contents':

  $('#iframe').ready(function() {
       $('#iframe').contents().find('a').attr('target', '_parent');
  });
Jeff B
  • 29,943
  • 7
  • 61
  • 90
  • 1
    Unfortunately, 'ready' doesn't work with iframes, so the content is probably not available when you call this. You need to wait, or provide a callback in your iframe. Or, use load as stated in another answer. But, contents should work if the frame is loaded and on the same domain. – Jeff B Apr 07 '11 at 15:28
  • You're right! awesome. it worked with a timeout on a function. – Daniel Node.js Apr 07 '11 at 15:30
1

Maybe because you could not modify the cross-domain iframe document in JavaScript.

Kara
  • 6,115
  • 16
  • 50
  • 57
KARASZI István
  • 30,900
  • 8
  • 101
  • 128