Reputation: 2738
I have an application where I want to save 100% of the contents of an iFrame. This includes the <html>
tags also (if they exist).
I have only found a solution on how to save the iFrame's content starting from the section.
var if = $('#myiframe').contents().find("html").html();
This however isn't good, because I don't know if theree always will be a HTML tag in the document. Also, the second problem with this approach is that it's not returning the <html>
tags.
I need some function with which I can return everything inside of an iFrame with no excuse.
Any idea how to achieve this?
Upvotes: 1
Views: 1219
Reputation: 2738
I have finally found a solution by doing the following:
var if = document.getElementById('#myiframe').contentWindow.document.documentElement.outerHTML;
Upvotes: 3