<html>
<head>
<script type="text/javascript">
function A() {
function B() {
alert('Running function B');
}
alert('Running function A');
}
onload = A;
</script>
</head>
<body>
</body>
</html>
If you try and call "B" onload instead of "A", you will get an error telling that "B is not defined" - which it isn't at the level you are trying to call it from. It exists only within the scope of function A, and thus can only be called from within function A.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.