Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > Can't get function caller if the caller is from a function within a popup window

Reply
Thread Tools

Can't get function caller if the caller is from a function within a popup window

 
 
Mark
Guest
Posts: n/a
 
      04-01-2004
The situtation is that I'm trying to ensure that certain functions are
only called by functions that I want them to be called from. I have a
popup window which has a function which calls a function in the opener
window (this works fine). The only thing is when I go to get the
caller property of the function in the opener window it is null, it
does not return the function in the popup window that called it.

Any ideas?
 
Reply With Quote
 
 
 
 
Richard Cornford
Guest
Posts: n/a
 
      04-01-2004
Mark wrote:
> The situtation is that I'm trying to ensure that certain functions are
> only called by functions that I want them to be called from. I have a
> popup window which has a function which calls a function in the opener
> window (this works fine). The only thing is when I go to get the
> caller property of the function in the opener window it is null, it
> does not return the function in the popup window that called it.


The - caller - property was not standardised into ECMAScript so it isn't
that widely supported. But separate browser windows are separate script
environments and they usually care about which window various object
belong to (functions being objects in this sense).

Usually though, you prevent functions that should not call other
functions form doing so by not coding the function calls into the bodies
of those functions. You seem to have something else in mind entirely, so
it is probably going to be necessary to answer the question: why?

Richard.


 
Reply With Quote
 
 
 
 
Mark
Guest
Posts: n/a
 
      04-03-2004
"Richard Cornford" <(E-Mail Removed)> wrote in message news:<c4hdd8$4ja$1$(E-Mail Removed)>...
> Mark wrote:
> > The situtation is that I'm trying to ensure that certain functions are
> > only called by functions that I want them to be called from. I have a
> > popup window which has a function which calls a function in the opener
> > window (this works fine). The only thing is when I go to get the
> > caller property of the function in the opener window it is null, it
> > does not return the function in the popup window that called it.

>
> The - caller - property was not standardised into ECMAScript so it isn't
> that widely supported. But separate browser windows are separate script
> environments and they usually care about which window various object
> belong to (functions being objects in this sense).
>
> Usually though, you prevent functions that should not call other
> functions form doing so by not coding the function calls into the bodies
> of those functions. You seem to have something else in mind entirely, so
> it is probably going to be necessary to answer the question: why?
>
> Richard.


Thanks for the reply Richard. I have since found a way to do what I
need without using the caller property. I had the popup function parse
its name as a string argument to the opener window function and then
eval the string to test if the popup function existed. The last line
of the popup function being self.close() so that the eval would fail
when the popup was closed. I also used the onFocus event handler in
the opener window to close the popup when it lost focus.
 
Reply With Quote
 
 
 
Reply

Thread Tools

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 On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Main window call Javascript function in popup window, and vice versa Jimmy Javascript 3 08-16-2007 02:48 PM
Popup Window Popup Timing =?Utf-8?B?Sm9obiBXYWxrZXI=?= ASP .Net 3 11-04-2005 07:33 PM
Function.caller if not called from within a function Thomas Mlynarczyk Javascript 4 02-26-2005 08:14 PM
New Popup Window from an existing Popup Window Raffi Javascript 4 08-12-2004 01:21 PM
Main > Popup > Popup > Close popup AND new URL in main? Jens Peter Hansen Javascript 7 06-19-2004 08:56 PM



Advertisments