Well, I have run my little test of this iFrame transfer code with every variation I can think of and it still doesn't work.
I'm trying to append the text, "This is inside frame.html...", to the test of the p tag with id of 'iFrame-content'. It seems so simple, but... I always get 'content' as null in the alert I've set up, as well as in console.log(content). Can someone please point out the error? Here's the code. Thanks, Rick! ----------------------------------------------------------------- main.html ----------------------------------------------------------------- <html> <head> <script type="text/javascript" src="jquery-1.2.6.min.js"></script> <script> function getContentFromIframe(iFrameName) { var content = $('#myIFrame').html(); console.log(content); alert(content); $(#myiFrame-content).append(content); </script> </head> <body> <iframe id='iFrameName' name='iFrameName' src='frame.html'></iframe> <a href="#" onclick="getContentFromIframe()">Get the content</a> <p id="iFrame-content"></p> </body> </html> --------------------------------------------------------------------- frame.html --------------------------------------------------------------------- <html> <head></head> <body> This is inside frame.html... </body> </html> --------------------------------------------------------------------- -----Original Message----- From: jquery-en@googlegroups.com [mailto:jquery...@googlegroups.com] On Behalf Of ricardobeat Sent: Wednesday, March 04, 2009 11:24 AM To: jQuery (English) Subject: [jQuery] Re: How do I translate this in jQuery? Oh, never noticed that funcionality, that's nice. The 'myIframe' var is unnecessary though. cheers, - ricardo On Mar 3, 3:38 pm, "Matt W." <propel...@gmail.com> wrote: > function getContentFromIframe(iFrameName) { > > var myIFrame = $("#"+iFrameName); > > var content = myIFrame.contents().find("body").html(); > > $('#myiFrame-content').append(content); > > On Mar 3, 9:56 am, "Rick Faircloth" <r...@whitestonemedia.com> wrote: > > > I've made various attempts at translating this into jQuery without success. > > > I guess I'm just not sufficient enough in regular JS to make it work. > > > It's working, but I'd like it to be written as much as possible in > > jQuery syntax. > > > Would some please translatethe first three lines of this into jQuery for me? > > > Thanks, > > > Rick > > > function getContentFromIframe(iFrameName) { > > > var myIFrame = document.getElementById(iFrameName); > > > var content = > > myIFrame.contentWindow.document.body(innerHTML); > > > $('#myiFrame-content').append(content); > > > -------------------------------------------------------------------- > > -------- > > ---------------------------------------------- > > > "My reading of history convinces me that most bad government results > > from too much government." > > > - Thomas Jefferson