Well I'll be durned.  I wonder if that's a change from earlier versions or
if I just missed it originally.

If both frames are from the same site, I don't know if a reason why that
should fail.

Does this return the DOM element in question?

$('input:[EMAIL PROTECTED]',window.frames["mainFrame"].document)[0];

And if so, does this fire it?

$('input:[EMAIL PROTECTED]',window.frames["mainFrame"].document)[0].click
();

JK

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On
Behalf Of Daemach
Sent: Thursday, April 12, 2007 6:46 PM
To: jQuery (English)
Subject: [jQuery] Re: How do I trigger the click event on a button in
another frame?


Actually, click with no arguments does trigger the event.

I'm not sure what you mean by different contexts - they are loaded
from the same site.

Another interesting thing is that if I do:

var mainFrame = parent.frames["mainFrame"].document; (from inside of
one of the frames)
console.log($(mainFrame));

it finds the right document, but trying to use mainFrame as a context
for a selector doesn't work.  ie:  console.log($('input',mainFrame));
== no good.

On Apr 12, 6:22 pm, "Jeffrey Kretz" <[EMAIL PROTECTED]> wrote:
> The jQuery method "click" is used to bind the click event -- it will not
> fire it.
>
> For example: $('a').click() will not fire the click event.  $('a').click(
> function() { /* do stuff */ } ) will bind to the event.
>
> $('a')[0].click() will fire the event, because its returning the first
> element of the jQuery collection (a specific DOM element) and firing it
> directly.
>
> The other thing you could run into is security issues if your two frames
are
> running under different contexts.
>
> JK
>
> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On
>
> Behalf Of Daemach
> Sent: Thursday, April 12, 2007 6:04 PM
> To: jQuery (English)
> Subject: [jQuery] How do I trigger the click event on a button in another
> frame?
>
> This started out as just a quick hack until I can redo the mechanism
> correctly, and now I just want to know how it works.
>
> $(window) has no properties, so $(window.frames[1].document) has no
> properties.  Oddly, window.frames[1].document in firebug pulls the
> correct document.  I've been trying to make the following work to no
> avail.  Is jQuery limited to the current document by design?
>
> $
>
('input:[EMAIL PROTECTED]',window.frames["mainFrame"].document).click();


Reply via email to