jQuery: The Write Less, Do More JavaScript Library

Get the real html from an iFrame

View: New views
3 Messages — Rating Filter:   Alert me  

Get the real html from an iFrame

by Mazi :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hallo all.

I have an iframe with an id.
I need to get the html content of this iframe.

So from the iframe doc read I tried like this

var html = parent.$('#indexIframe').contents().find('html').html()

In this way I get the content of the tag html of the iframe, so the
head definition and the body definition.

<head>...</head>
<body>...</body>

I would like to get the parent tag in a way to have:

<html>
  <head>...</head>
  <body>...</body>
</html>

Any idea?
Kind regards

Massimo


Re: Get the real html from an iFrame

by brian ally-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Do either of these work?

var html = parent.$('#indexIframe').contents().html();
var html = parent.$('#indexIframe').contents();

On Wed, Nov 11, 2009 at 9:49 AM, m.ugues <m.ugues@...> wrote:

> Hallo all.
>
> I have an iframe with an id.
> I need to get the html content of this iframe.
>
> So from the iframe doc read I tried like this
>
> var html = parent.$('#indexIframe').contents().find('html').html()
>
> In this way I get the content of the tag html of the iframe, so the
> head definition and the body definition.
>
> <head>...</head>
> <body>...</body>
>
> I would like to get the parent tag in a way to have:
>
> <html>
>  <head>...</head>
>  <body>...</body>
> </html>
>
> Any idea?
> Kind regards
>
> Massimo
>
>

Re: Get the real html from an iFrame

by Mazi :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

None of those worked out.

Any idea how to get all the html with a jqeury selector?

Kind regards

Massimo

On 12 Nov, 15:00, brian <zijn.digi...@...> wrote:

> Do either of these work?
>
> var html = parent.$('#indexIframe').contents().html();
> var html = parent.$('#indexIframe').contents();
>
> On Wed, Nov 11, 2009 at 9:49 AM, m.ugues <m.ug...@...> wrote:
> > Hallo all.
>
> > I have an iframe with an id.
> > I need to get the html content of this iframe.
>
> > So from the iframe doc read I tried like this
>
> > var html = parent.$('#indexIframe').contents().find('html').html()
>
> > In this way I get the content of the tag html of the iframe, so the
> > head definition and the body definition.
>
> > <head>...</head>
> > <body>...</body>
>
> > I would like to get the parent tag in a way to have:
>
> > <html>
> >  <head>...</head>
> >  <body>...</body>
> > </html>
>
> > Any idea?
> > Kind regards
>
> > Massimo