dzLib.js
 

callerStack

Description:
This function shows the caller-stack-chain (who called who, and who called him, and so on). Handy for debugging purposes, so you can see which function initiated the call.

IE and OmniWeb on Mac seem to name the functions of an HTMLElement-event. On Windows, the originating function is anonymous but on Mac it's onclick. Pretty neat, eh

Doesn't work in Mozilla. The sentences caller is no longer used. and The caller property is available only within the body of a function. from DevEdge do not point into a direction for a solution

Download: code, view-source.
Targetted: all
Tested on: ie4.0-6.0/Win, ie5.2/Mac, OmniWeb4.1/Mac
Fails on: moz1.0/1.1

Usage

function Show() { alert( callerStack() ); }
function Call(s) { Show(); }
function Stack(n) { Call('String argument'); }
function Chain(b,n) { Stack(-12.34567e+89); }

var fFunctionRef=Chain;

Live Demo

The following button calls a function, and that function calls another function. This is done 4 times, before a call is made to callerStack(). Do a view source for the code.