Well, I dunno of any way to automatically trap events of an iframe but you
could certainly work something out by overriding the events handlers of the
elements in the iframe you're interested with scripting from the parent
document. Of course it's IF AND ONLY IF your page and the iframe are of the
same domain because, otherwise, you can't access the iframe document for
security reasons.
Anyway, given you managed the plumbery to get the iframe window object, it's
quite easy to add to it. Say you have it in a variable called win, you can
override the global onerror event of the window with the following code:

win.onerror = function() {
  // Your code from the main page here
  window; // The window object of the main page
  this; // The window object of the iframe
}

Haven't tested jQuery this way but I guess you could do something like:

$("button",win.document).click(...);

To add click notifiers to buttons in the iframe. (Please anyone correct me
if I'm wrong).

Another solution if you have control of the content in the iframe, is to
call functions & methods declared in the main page from the iframe using the
parent variable. So in the iframe, you could have:

parent.myObject.myNotifier(data);

and inform the main page that way.

Anyway, maybe you knew all this and I guess you're trying to get a trick in
the cross-domain department and I'm afraid it's a no go because of security
barriers in the browsers.

2009/3/12 <[email protected]>

> I think no because if this were possible it will be a security
> vulnerability
> Or not?
>
> PRIX IT -development -engeneering -consultant
>
> -----Original Message-----
> From: ECS <[email protected]>
>
> Date: Thu, 12 Mar 2009 13:35:04
> To: jQuery Development<[email protected]>
> Subject: [jquery-dev] Iframe and jQuery
>
>
>
> This has been asked a million times before probably, but is there any
> way to trap events in the iframe window and pass the events to the
> parent window, not bothering about the URL of the SRC of the iframe?
> Any help would be appriciated. Thanks a ton!
>
>
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"jQuery Development" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/jquery-dev?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to