0
 <script> 

jQuery("iframe").load(function() {

 console.log('can you hear me?');

 $('iframe').contents().find('#findme').html('lorium ipsom');  

});

 </script>

I am having trouble getting this to work. I am trying to find a div inside of an iframe (on the same server) and then inject some html in there.

Any thoughts?

tshepang
  • 12,111
  • 21
  • 91
  • 136

1 Answers1

0

The source inside of iframes are 'protected' from outside modification. This helps to prevent XSS (cross site scripting) attacks. What you're wanting semi-violates the same-origin policy.

The only way to make it happen is to add the javascript to the document inside the iframe itself.

Casey Dwayne
  • 2,142
  • 1
  • 17
  • 32
  • are you sure??? [http://stackoverflow.com/questions/364952/jquery-javascript-accessing-contents-of-an-iframe](http://stackoverflow.com/questions/364952/jquery-javascript-accessing-contents-of-an-iframe) –  May 23 '13 at 19:34