Internal scripts and Functions

Internal Scripts can be either in the Body or Head section of a web page

Internal Scripts in the Head using Functions
- a function is placed in head and called by an event such as a mouse click.
- the javascript is only executed when the function is called by the event.
- creating functions like this has several advantages including allowing the same function to be called several times.

Lets create our Example with this approach
Click me
Here is the code.
	<head>  
	<script>  	
	function hi(){  
		window.alert('hi there');  
	} 
	</script>  
	</head> 
In Body of HTML

<body> <div onclick="hi();">Click me</div> </body>

When the user clicks on the link in the body, the function hi(), which is stored in the Head, is executed.

Exercise
Use the code snippets above to create a page a and make sure the click works