I need to grab content from an iFrame, preferably using jQuery. However, I have no clue how to do this.
First off, I'm inserting the iFrame into the page: <script> $(function() { $("#divID").after("<iframe src='http://example.com/test/test.html' name='tesaaat' id='tesaaat' height='0' width='0'></iframe>"); }); </script> Now then, test.html looks something like this: <html> <head><title>Test</title></head> <body> <div id="example">Text</div> </body> </html> I need to pull out the text in #example. I tried this <script> $(function() { $("#divID").after("<iframe src='http://example.com/test/test.html' name='tesaaat' id='tesaaat' height='0' width='0'></iframe>"); var something = $("parent.frames['tesaaat'].document > #example").text(); }); </script> But for some reason this doesn't work. When I try alert(something) it alerts a box with nothing, and oddly enough it does it twice. I searched around a bit but didn't find anything that could help me, and this should be simple I think. Anyone got any clues? Thanks.