开发者

body html of iframe

开发者 https://www.devze.com 2022-12-09 16:58 出处:网络
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?

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");
0

精彩评论

暂无评论...
验证码 换一张
取 消