[thelist] Substitute for arguments.caller?

Lee Kowalkowski lee.kowalkowski at googlemail.com
Thu Jun 21 08:07:11 CDT 2007

On 21/06/07, liorean <liorean at gmail.com> wrote:
> On 21/06/07, Marcus Bristav <marcus.bristav at gmail.com> wrote:
> > Today I'm using arguments.caller to get my own stack trace whenever I
> > want to debug an exception or find out who is calling me and then
> > prints it to some div or something (yeah, I know I can use Firebug but
> > we're developing Ajax applications on IPTV STBs). Opera doesn't
> > support arguments.caller as far as I know. Is it possible to get the
> > same behaviour on Opera somehow (Opera 8 mainly)
> IIRC the standard has it as arguments.callee.caller, not as
> arguments.caller. See if changing to that one makes it work in Opera.

It's actually function.caller, e.g. function
abc(){alert(abc.caller);}.  Although going via arguments.callee is the
same difference, but arguments.callee only really exists to support
recursive anonymous functions.

Caller isn't defined in ECMAScript, and doesn't work in Opera
(http://www.opera.com/docs/specs/js/ecma/) or Safari (so I'm told).

You can resort to passing in your functions as parameters, not nice.
Or before you invoke a function, you can set its caller property, not
nice either (it's read-only anyway except for where its not supported,
then it'll work, but you'll also be able to set it to something

Of course, unless Opera itself has some native stack-trace feature,
but I can't find anything about that.


More information about the thelist mailing list