views:

42

answers:

3

Hi my code returns all the html of the iframe. I would like just the body html. Any one know how to amend to suit?

Code:

alert( $("#uploaderIframe").contents()[0].documentElement.innerHTML );
A: 

Try this:

iframeHtml = $("#uploaderIframe").contents()[0].documentElement.innerHTML;
bodyHtml = $(iframeHtml).find("body");
kgiannakakis
A: 
var iframeHtml = $("#uploaderIframe").contents()[0].documentElement.innerHTML;
var bodyHtml = $(iframeHtml).find("body");
alert( bodyHtml );

returned object object

var iframeHtml = $("#uploaderIframe").contents()[0].documentElement.innerHTML;
var bodyHtml = $(iframeHtml).find("body").html();
alert( bodyHtml );

returned null

any ideas?

Phil Jackson
A: 
var iframeHtml = $("#uploaderIframe").contents()[0].documentElement.innerHTML;
var bodyHtml = $(iframeHtml).find("body").html();
alert( bodyHtml );

.. probably creates a new DOM node from the innerHTML of the iFrame - I actually suspect that $(iframeHtml).find("body") is an empty jQuery object.

Try

var bodyHtml = $('#uploaderIframe').contents().find("body").html()

Ref: Traversing/contents

K Prime
thankyou perfect
Phil Jackson