Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Calling a function

Status
Not open for further replies.

iaswnidou

Programmer
Joined
Apr 19, 2005
Messages
140
Location
GR
Hello

I have an external js file with lots of functions that i refer to from each of my asp.net pages.

Can i call a function within another function in that file?Will that get executed?
 
To demonstrate:

Code:
<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.

Dan

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top