开发者

javascript or jquery code to obtain entire text content of web page within an iframe (including/excluding links on that page)

I know how to obtain the content of div within an iframe using jquery--

iframe content:

    <div id="myContent"></div>

jQuery:

 $("#myiframe").find("#myContent")

What I want to do is, obtain the entire text content of an iframe, both with the text of all links wit开发者_开发问答hin that iframe, as well as text content excluding the link texts within that iframe.

I want to do this ideally using jquery, but pure js or jquery+ js is also fine with me.


You can use .contents()

<iframe src="your_url.com" id='myiframe'></iframe>

To get the whole content from iframe

$("#frameDemo").contents()

To get the data from specific element.

$("#myiframe").contents().find("#myContent")
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜