- This topic is empty.
Viewing 6 posts - 1 through 6 (of 6 total)
Viewing 6 posts - 1 through 6 (of 6 total)
- The forum ‘JavaScript’ is closed to new topics and replies.
The forums ran from 2008-2020 and are now closed and viewable here as an archive.
Home › Forums › JavaScript › Download code within iframe as html file
I have an iframe that links to one of my other pages and i basically want to download all the HTML code within that iframe as an .html file. Is this possible with jQuery?
The method can’t require a server because it will be locally, and if downloading from an iframe is not possible without a server, than downloading the html within a div would be the next thing.
You can use yourIFrame
.contentWindow
to get at the contents of an iframe.
Plain ol’ JS; jQuery is not needed.
Right. And after getting the iframe content, how do I download the .html with that content when a button is clicked?
How would it be done if the content is within a div? just curious.
You could create a hyperlink and encode the contents as a data URI:
someone else’s demo
That’s probably the simplest/most reliable method, but I think performance would depend on the size of the contents.
How would it be done if the content is within a div?
Same way. The only difference would be in how you get the page contents.
I have an iframe that links to one of my other pages and i basically want to download all the HTML code within that iframe as an .html file. Is this possible with jQuery?
I know this is probably a silly question but if the linked iframe is to one of your pages…why do you need to download it?.
You own the files…copy and paste.
@Paulie_D its something that others will use when downloaded.
@_ thanks
Is is also possible to take content from the iframe and appended to the actual page? for example if theres a div within that iframe and i click it, can i take that same div and append it somewhere outside the iframe? or is there i cross-browser origin issue?