Javascript: / Home / InternalScript

Internal Script

In most cases there will be several lines of code that need to be executed for an event handler. For these cases the "script" element can be added to the "head" element. The Script element can contain Javascript Functions.

Javascript functions are blocks of code that have a unique name. The code in a function is contained within the opening and closing braces.

The code in a function can be executed by using the function name. This is referred to as "Calling" the function or a function "Call".

    <script>
      function GoToInlineEvent()
      {
        window.location.href = "5InlineEvent.html";
      }
    </script>

The event handler assignment now looks like this:
<button onclick="GoToInlineEvent()"><- InlineEvent</button>

In this case the functionality is exactly the same but it makes for much cleaner code. Also the handler function can be called from other places in the page which prevents duplication.

EventProperty ->            ExternalScript ->
6InternalScript