Hi my code returns all the html of the iframe. I would like just the body ht开发者_StackOverflow中文版ml. Any one know how to amend to suit?
Code:
alert( $("#uploaderIframe").contents()[0].documentElement.innerHTML );
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
Try this:
iframeHtml = $("#uploaderIframe").contents()[0].documentElement.innerHTML;
bodyHtml = $(iframeHtml).find("body");
精彩评论