Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



Reply
using addEventListener / attachEvent to listen for function calls
Old 03-05-2007, 03:19 PM using addEventListener / attachEvent to listen for function calls
foobar's Avatar
Extreme Talker

Posts: 225
Trades: 0
Here's the rundown on what I'm looking for.

I have a main page. This main page receives a parameter which is a ; delimited list of Javascript files to include. On page load, it takes this parameter, splits it on ';' and writes a <script></script> block in the head to include each file.

This works perfectly.

The main page has an iframe, which includes a page passed as a parameter also. This, again, works fine.

The issue is with the iframe page calling functions defined on the Main page (its parent). If I call a function that's been defined in the parent from the iframe, I get a "function undefined" error, which is to be expected. Adding parent in front of the function works, and it'll call the parent page's function. I don't want to do this.

I want the iframe to trap all functions called from within itself. If the function isn't defined, it'll "move up" and call the function on the parent page. Essentially, this means the child page (in the iframe) can redefine functions, essentially overriding the Main page's, which is exactly what I want to do.

However, while I can trap DOM events such as click, mousedown, etc. using addEventListener, I can't seem to find how to trap a function call (be it all the functions or specific ones).

My questions:
a) Is this possible;
b) If so, can I listen for EVERY function called and pick up the name of the function that was being called from the event object, and use it to call parent.function(). If not, is it possible to add listeners for specific, user-defined functions.

Thanks for your time.
foobar is offline
Reply With Quote
View Public Profile Visit foobar's homepage!
 
 
Register now for full access!
Reply     « Reply to using addEventListener / attachEvent to listen for function calls
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.16615 seconds with 12 queries