471,343 Members | 1,290 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,343 software developers and data experts.

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

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?
Jul 20 '05 #1
2 1737
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.
Jul 20 '05 #2
"Richard Cornford" <Ri*****@litotes.demon.co.uk> wrote in message news:<c4*******************@news.demon.co.uk>...
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.
Jul 23 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Sushil Srivastava | last post: by
2 posts views Thread by Michelle Stone | last post: by
7 posts views Thread by =?UTF-8?B?QW50w7NuaW8gTWFycXVlcw==?= | last post: by
reply views Thread by rosydwin | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.