Created
March 8, 2009 04:27
-
-
Save snaka/75567 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html><head><title>JS Stack trace for IE</title> | |
<script type="text/javascript"> | |
// --- stack trace --- | |
function stackTrace() { | |
var caller = arguments.callee.caller; | |
var stack = funcName(caller) + '<br/>' + | |
walker(caller.arguments.callee.caller); | |
window.open().document.write(stack); | |
function walker(caller) { | |
if (!caller) return; | |
var result = ' ... ' + funcName(caller) + '<br/>'; | |
result += walker(caller.arguments.callee.caller) || ''; | |
return result; | |
} | |
function funcName(name) { | |
return name.toString().match(/function\s+(\S+\(\S*\))/)[1]; | |
} | |
} | |
// --- usage example --- | |
function calltop() { intermidiate1() } | |
function intermidiate1() { intermidiate2() } | |
function intermidiate2() { intermidiate3() } | |
function intermidiate3() { callfunc() } | |
function callfunc() { | |
stackTrace(); | |
} | |
</script></head> | |
<body> | |
<button onclick="calltop()">RUN</button> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment