Internal scripts

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

In either case we use the script tag to enclose the code

Body Script

<body>
Some text
<script type='text/javascript'>
window.alert('hi there');
</script>
Some other stuff
</body>

We use window.alert() which is an optional and more formal way of calling an alert box.
(alert() is actually a method of the window object)

Exercise
Create the web page above and display it in a browser

When you try this example you will notice the alert box is displayed as the page is loading.
This is because the script is in the body of the page.
We can make the script wait for some user action by placing it inside a function in the head section of a web page.