JavaScript Programming: External Scripting vs. Internal Scripting and Event Handlers, Exercises of Java Programming

The difference between external scripting and internal scripting in javascript, as well as the concept of event handlers. External scripting involves keeping functionality in a separate javascript file and including it in html documents, while internal scripting means writing the code directly into the html document. Event handlers are simple functions that can be called against mouse or keyboard events. The document also covers variables, operators, and basic scripting rules.

Typology: Exercises

2017/2018

Uploaded on 05/07/2018

muhammad-waqas-7
muhammad-waqas-7 🇵🇰

1 document

1 / 3

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
External Scripting:
If the functionality to be defined is used in various HTML documents then its better to keep
that functionality in a separate Javascript file and then include that file in your HTML docx.
E.g.
<html>
<head>
<title></title>
<script src="any_file.js" type="text/javascript">
</script>
</head>
<body>
<input type="button" onclick="External();" value="Click here">
</body>
</html>
---------------------------------------------
Internal Scripting
The code can be written directly into the HTML document.
e.g.
<html>
<head>
<title></title>
<script type="text/javascript">
function internal(){
alert("Internal Script");
}
</script>
</head>
<body>
<form>
<input type="button" onclick="internal();" value="Click here">
</form>
</body>
</html>
--------------------
Event Handler:
Event handlers are simple defined functions which can be called against any mouse or
keyboard event.
pf3

Partial preview of the text

Download JavaScript Programming: External Scripting vs. Internal Scripting and Event Handlers and more Exercises Java Programming in PDF only on Docsity!

External Scripting:

If the functionality to be defined is used in various HTML documents then its better to keep that functionality in a separate Javascript file and then include that file in your HTML docx.

E.g.


Internal Scripting

The code can be written directly into the HTML document. e.g.


Event Handler: Event handlers are simple defined functions which can be called against any mouse or keyboard event.

Bring your mouse here to see the alert message


Variables: Variables are containers for storing data values. They are assigned values using the equal sign (=).

Scripting rules:

  1. variables can hold numbers and text values.
  2. text values are called text strings.
  3. Strings can be written in double or single quotes.
  4. All variables must be identified with unique names.
  5. These variable names are called identifiers.
  6. Variable name must begin with a letter.
  7. Variable names are CASE-SENSITIVE.

Operators:

  • Addition
  • Subtraction
  • multiplication / division % modulus ++ increment -- decrement == equivalent to (values only) === equal value and equal type (data type) != not equal !== not equal value < less than > greater than <= less than or equal to >= greater than or equal