The Sysadmin Notebook  

Sitemap

Code Execution

Execution order of scripts as document loads

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
http://www.w3.org/TR/html4/strict.dtd">
<html dir="ltr" lang="en">
<head>
    <link rel='stylesheet' media="screen" type='text/css' href='/css/floatlr.css' />
    <link rel='stylesheet' media="print" type='text/css' href='css/floatlrprint.css' />
    <link rel="shortcut icon" href="icons/favicon.ico" />
	<script type="text/javascript">
		alert('First script Block ');
		alert('First script Block - Second Line ');
	</script>
</head>
<div id="content">
<body>
	<h1>Code Execution Order</h1>
	<script type="text/javascript">
			alert('Second script Block ');
	</script>
	<p>There are four script blocks in this document</p>
	<script type="text/javascript">
		alert('Third script Block');
		function doSomething() {
			alert('Function in Third script Block');
		}
	</script>
	<p>Third script block has finished but function doesn't execute, until it is called.</p>
	<script type="text/javascript">
		alert('Ready to call function in third Block?');
		doSomething();	
	</script>
</div>