V
VK
And this script supposes to work everywhere. It allows to get the name
of any function from within the function itself.
<html>
<head>
<title>Function name</title>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1">
<script type="text/javascript">
function test() {
var myName = getFunctionName(arguments.callee);
alert(myName);
}
function getFunctionName(f) {
var tmp = f.toString();
var re = /(\s*function\s+)(\w+)(\s*\()/m;
re.exec(tmp);
return RegExp.$2;
}
</script>
</head>
<body bgcolor="#FFFFFF" onload="test()">
</body>
</html>
of any function from within the function itself.
<html>
<head>
<title>Function name</title>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1">
<script type="text/javascript">
function test() {
var myName = getFunctionName(arguments.callee);
alert(myName);
}
function getFunctionName(f) {
var tmp = f.toString();
var re = /(\s*function\s+)(\w+)(\s*\()/m;
re.exec(tmp);
return RegExp.$2;
}
</script>
</head>
<body bgcolor="#FFFFFF" onload="test()">
</body>
</html>