[jQuery] Re: How to catch function call

2008-07-08 Thread Luiz Abrahao

Hi Michael,

I tried, but I've got no response. I double checked the spelling (the
iframe's id and the javascript function's name), and the function is
global.

What I did:

- I'm using jquery-1.2.6.min.js
- inside my head tag I have:



;(function( $ ) {
   $.fn.frameHook = function( name, hook ) {
  this.each( function() {
 var win = this.contentWindow;
 var target = win[name];
 win[name] = function() {
hook.apply( win, arguments );
return target.apply( win, arguments );
 };
  });
   };
})( jQuery );

$('#course').frameHook( 'trivNextPage', function() {
   alert( 'about to call trivNextPage' );
});




but nothing happens when I trigger the trivNextPage function, if I
assign a breakpoint to the line "$
('#course').frameHook( 'trivNextPage', function()" the the firebug
(1.2.0b4) only stops at this point when the page is refreshed. but the
function never is executed.

I don't know if I'm doing something stupid.

Many Thanks
Luiz


On Jul 4, 9:18 pm, "Michael Geary" <[EMAIL PROTECTED]> wrote:
> That's good - if it were a different domain we'd be in trouble!
>
> I forgot to ask, but the JavaScript function you want to intercept is a
> global function in the iframe, correct? Then you could use something like
> this plugin (untested):
>
>     ;(function( $ ) {
>         $.fn.frameHook = function( name, hook ) {
>             this.each( function() {
>                 var win = this.contentWindow;
>                 var target = win[name];
>                 win[name] = function() {
>                     hook.apply( win, arguments );
>                     return target.apply( win, arguments );
>                 };
>             });
>         };
>     })( jQuery );
>
> Given an iframe with id="myframe" and a global function inside the iframe
> named 'foobar', you would do:
>
>     $('#myframe').frameHook( 'foobar', function() {
>         alert( 'about to call foobar' );
>     });
>
> To help illustrate, here's a bare metal version without the jQuery
> boilerplate:
>
>     function frameHook( iframe, name, hook ) {
>         var win = iframe.contentWindow;
>         var target = win[name];
>         win[name] = function() {
>             hook.apply( win, arguments );
>             return target.apply( win, arguments );
>         };
>     }
>
>     var iframe = $('#myframe')[0];
>     frameHook( iframe, 'foobar', function() {
>         alert( 'about to call foobar' );
>     });
>
> -Mike
>
> > From: Luiz Abrahao
> > Michael, thanks for your time,
>
> > It's loaded form the same domain.
>
> > > On Jul 3, 3:41 pm, "Michael Geary" <[EMAIL PROTECTED]> wrote:
> > > Is the iframe loaded from the same domain as the containing
> > > page, or a different domain?
>
> > > > From: Luiz Abrahao
> > > > I have one page with one iframe, and there are few javascript
> > > > function on the page inside the iframe. These functions are
> > > > triggered by some flash presentations.
>
> > > > Basically the parent page has to 'know' when the user has
> > > > requested the next page (inside the iframe) and update its content
> > > > with relevant data related with this new page inside the iframe.
>
> > > > I can't change the javascript functions from the pages inside the
> > > > iframe.
>
>


[jQuery] Re: How to catch function call

2008-07-04 Thread Michael Geary

That's good - if it were a different domain we'd be in trouble!

I forgot to ask, but the JavaScript function you want to intercept is a
global function in the iframe, correct? Then you could use something like
this plugin (untested):

;(function( $ ) {
$.fn.frameHook = function( name, hook ) {
this.each( function() {
var win = this.contentWindow;
var target = win[name];
win[name] = function() {
hook.apply( win, arguments );
return target.apply( win, arguments );
};
});
};
})( jQuery );

Given an iframe with id="myframe" and a global function inside the iframe
named 'foobar', you would do:

$('#myframe').frameHook( 'foobar', function() {
alert( 'about to call foobar' );
});

To help illustrate, here's a bare metal version without the jQuery
boilerplate:

function frameHook( iframe, name, hook ) {
var win = iframe.contentWindow;
var target = win[name];
win[name] = function() {
hook.apply( win, arguments );
return target.apply( win, arguments );
};
}

var iframe = $('#myframe')[0];
frameHook( iframe, 'foobar', function() {
alert( 'about to call foobar' );
});

-Mike

> From: Luiz Abrahao
> Michael, thanks for your time,
> 
> It's loaded form the same domain.
> 
> > On Jul 3, 3:41 pm, "Michael Geary" <[EMAIL PROTECTED]> wrote:
> > Is the iframe loaded from the same domain as the containing 
> > page, or a different domain?
> >
> > > From: Luiz Abrahao
> > > I have one page with one iframe, and there are few javascript 
> > > function on the page inside the iframe. These functions are 
> > > triggered by some flash presentations.
> > >
> > > Basically the parent page has to 'know' when the user has 
> > > requested the next page (inside the iframe) and update its content
> > > with relevant data related with this new page inside the iframe.
> > >
> > > I can't change the javascript functions from the pages inside the 
> > > iframe.



[jQuery] Re: How to catch function call

2008-07-04 Thread Luiz Abrahao

Michael, thanks for your time,

It's loaded form the same domain.


On Jul 3, 3:41 pm, "Michael Geary" <[EMAIL PROTECTED]> wrote:
> Is the iframe loaded from the same domain as the containing page, or a
> different domain?
>
> > From: Luiz Abrahao
>
> > I have one page with one iframe, and there are few javascript
> > function on the page inside the iframe. These functions are
> > triggered by some flash presentations.
>
> > Basically the parent page has to 'know' when the user has
> > requested the next page (inside the iframe) and update its
> > content with relevant data related with this new page inside
> > the iframe.
>
> > I can't change the javascript functions from the pages inside
> > the iframe.
>
> > Thanks
> > Luiz.
>
>


[jQuery] Re: How to catch function call

2008-07-04 Thread Luiz Abrahao

Hi Micheael,

Thanks for your time.

Yes, it is. The pages that are loaded into the iframe are form the
same domain.

Thanks

On Jul 3, 3:41 pm, "Michael Geary" <[EMAIL PROTECTED]> wrote:
> Is the iframe loaded from the same domain as the containing page, or a
> different domain?
>
> > From: Luiz Abrahao
>
> > I have one page with one iframe, and there are few javascript
> > function on the page inside the iframe. These functions are
> > triggered by some flash presentations.
>
> > Basically the parent page has to 'know' when the user has
> > requested the next page (inside the iframe) and update its
> > content with relevant data related with this new page inside
> > the iframe.
>
> > I can't change the javascript functions from the pages inside
> > the iframe.
>
> > Thanks
> > Luiz.
>
>


[jQuery] Re: How to catch function call

2008-07-03 Thread Michael Geary

Is the iframe loaded from the same domain as the containing page, or a
different domain? 

> From: Luiz Abrahao
> 
> I have one page with one iframe, and there are few javascript 
> function on the page inside the iframe. These functions are 
> triggered by some flash presentations.
> 
> Basically the parent page has to 'know' when the user has 
> requested the next page (inside the iframe) and update its 
> content with relevant data related with this new page inside 
> the iframe.
> 
> I can't change the javascript functions from the pages inside 
> the iframe.
> 
> Thanks
> Luiz.