Ayaz Ali Khatri
Ayaz Ali Khatri

Reputation: 483

Javascript: Get body of an ID

I am trying to get body content of iframe using either Javascript or jQuery. I have tried to solve the problem several ways, but none of them worked for me.

The solutions I tried looked like these:

document.getElementById('iframe').document.innerHTML;

$("#content").contents().find("body").html();

Upvotes: 0

Views: 324

Answers (2)

user1526546
user1526546

Reputation:

document.getElementById("iframe").contentWindow.document.body.innerHTML

Upvotes: 3

Will Hawker
Will Hawker

Reputation: 733

If the iframe is from the same domain, you could do an $.ajax request on the URL that is the iframe src url?

Upvotes: 1

Related Questions