Google Groups Home
Help | Sign in
how to address to iframe content with jquery ?
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  8 messages - Collapse all
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
EugeneS  
View profile
 More options Mar 12, 7:47 pm
From: EugeneS <SEuge...@gmail.com>
Date: Wed, 12 Mar 2008 16:47:32 -0700 (PDT)
Local: Wed, Mar 12 2008 7:47 pm
Subject: how to address to iframe content with jquery ?
Hello,

so lets imagine i have some iframe inside my html page:
<iframe width="750" scrolling="no" height="255" src="http://
www.some_url.com/some_page.htm"></iframe>

how can i work with the loaded content ?

i was trying something like:
aa = $('iframe').html();

$("div > img", $(aa)).each(
                                        function(){
                                                                if ($(this).parent('div').attr('style'))
                                                                {
                                                                        $(this).parent('div').click(function(){
                                                                                                                                                alert("Hello2");
                                                                                                                                });
                                                                }
                                        });

to clarify this: i want to add onClick event to some IMG which is
inside DIV and this DIV inside this url http://www.some_url.com/some_page.htm
which is loaded in IFRAME...

how can i add some onClick event to some image which is loaded in
iframe ?

finally stuck :(


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
chrismarx  
View profile
 More options Mar 12, 10:00 pm
From: chrismarx <chrism...@gmail.com>
Date: Wed, 12 Mar 2008 19:00:03 -0700 (PDT)
Local: Wed, Mar 12 2008 10:00 pm
Subject: Re: how to address to iframe content with jquery ?
i use this:

$('iframe').contents().find('div').each(function(){
    //etc

});

On Mar 12, 7:47 pm, EugeneS <SEuge...@gmail.com> wrote:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Patrik Nikkanen  
View profile
 More options Mar 13, 6:13 am
From: "Patrik Nikkanen" <patrik.nikka...@dwm.se>
Date: Thu, 13 Mar 2008 11:13:26 +0100
Local: Thurs, Mar 13 2008 6:13 am
Subject: Re: [jQuery] how to address to iframe content with jquery ?
Read:
http://docs.jquery.com/Traversing/contents

Example:
var oBody = $("#MyIFrame").contents().find("body");
oBody.append('<h1 id="hello">Hello world</h1>');
$('#hello', oBody).bind('click', function () { alert('Why, hello there!')});


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
simo  
View profile
 More options Mar 13, 7:43 am
From: simo <simon.geor...@gmail.com>
Date: Thu, 13 Mar 2008 04:43:34 -0700 (PDT)
Local: Thurs, Mar 13 2008 7:43 am
Subject: Re: how to address to iframe content with jquery ?
Hi,

adapting your script I'm trying to access the content between my
Iframe <body> tag but i'm not able to ...

here is my code :

------
var iBody = $jq("#mce_editor_0").contents().find("<body>");
alert('iframe:'+ iBody);
alert('iframe:'+ iBody.html());
--------

alert('iframe:'+ iBody);  displays an object
alert('iframe:'+ iBody.html()); displays null

Which method should I use? Thanks.

On Mar 13, 3:13 pm, "Patrik Nikkanen" <patrik.nikka...@dwm.se> wrote:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
chrismarx  
View profile
 More options Mar 13, 7:55 am
From: chrismarx <chrism...@gmail.com>
Date: Thu, 13 Mar 2008 04:55:56 -0700 (PDT)
Local: Thurs, Mar 13 2008 7:55 am
Subject: Re: how to address to iframe content with jquery ?
should be like the example:

var oBody = $("#MyIFrame").contents().find("body");

notice:(no "<" ">")

On Mar 13, 7:43 am, simo <simon.geor...@gmail.com> wrote:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
simo  
View profile
 More options Mar 13, 8:01 am
From: simo <simon.geor...@gmail.com>
Date: Thu, 13 Mar 2008 05:01:02 -0700 (PDT)
Local: Thurs, Mar 13 2008 8:01 am
Subject: Re: how to address to iframe content with jquery ?
actually I want to put all the content in another element.

So i did this :

var iBody = $jq("#mce_editor_0").contents().find("<body>");
$jq("textarea#message").val(iBody.html());

But it's not working.

thanks for your help

On Mar 13, 4:43 pm, simo <simon.geor...@gmail.com> wrote:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Patrik Nikkanen  
View profile
 More options Mar 13, 8:55 am
From: "Patrik Nikkanen" <patrik.nikka...@dwm.se>
Date: Thu, 13 Mar 2008 13:55:12 +0100
Local: Thurs, Mar 13 2008 8:55 am
Subject: Re: how to address to iframe content with jquery ?
Hi
Your problem probably is the extra <> tags inside the .find()
Try:

var iBody = $jq("#mce_editor_0").contents().find("body");
alert('iframe:'+ iBody.html());

or maybe

var iBody = $("#mce_editor_0").contents().find("body");


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
simo  
View profile
 More options Mar 13, 10:21 am
From: simo <simon.geor...@gmail.com>
Date: Thu, 13 Mar 2008 07:21:32 -0700 (PDT)
Local: Thurs, Mar 13 2008 10:21 am
Subject: Re: how to address to iframe content with jquery ?
I noticed it and forgot to remove them!

sorry, and thank you chrismark!

On Mar 13, 4:55 pm, chrismarx <chrism...@gmail.com> wrote:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2008 Google