August 1999
Intermediate to advanced
1488 pages
72h 53m
English
function.caller
The caller property of the Function object is used to reference the function that called the currently executing function.
Listing 6.129 shows how the caller property is used to get the name of the function calling John().
<html>
<body>
<script lanuguage="JavaScript1.1">
<!–– Hide
// Define a simple function Alice(), which calls the John() function.
function Alice(){
var Boss = true;
John();
}
// function outputs its caller
function John(){
myBoss = John.caller.name;
document.write("The boss is: " + myBoss + "<br>");
}
// End Hide ––>
</script>
</body>
</html>
|
Read now
Unlock full access