Introduction To JavaScript Notes
Introduction To JavaScript Notes
JavaScript is programming code inserted into an HTML page. It is used to make web pages more
dynamic as well as interactive.
JavaScript is different from HTML because JavaScript is used to create more dynamic web pages
while HTML is a markup language that is used to create static content on the web page.
JavaScript code is inserted in a HTML file by using the <script> tag. No special program is
required in order to write code in JavaScript as it is an interpreted language. You can use any text
editor such as Notepad in order to write JavaScript code
©Juliet 2023
Page 1
Introduction to JavaScript 2023
JavaScript Syntax:
A JavaScript consists of JavaScript statements that are placed within the <script>... </script>
HTML tags in a web page.
You can place the <script> tag containing your JavaScript anywhere within you web page but it
is preferred way to keep it within the <head> tags.
<script>
JavaScript code
</script>
Exercise1
Create an HTML page with some embedded JavaScript code to output the statement “This is my
first JavaScript page” when ran via web browser.
Exercise Two
Create an HTML page with some embedded JavaScript code to output the statements shown
below:-
<html>
<Body>
©Juliet 2023
Page 2
Introduction to JavaScript 2023
<p>
</p>
<script>
</script>
</body>
</html>
Exercise 2
A function is a block of code that will be executed when the user calls it.
An illustration of the use of the alert () function to React to the user Event of clicking on a button
displayed on HTML page
©Juliet 2023
Page 3
Introduction to JavaScript 2023
Exercise one:
Create an HTML page with some embedded Java script code to create a button named “Click on
this button” which displays the output “Karibu Sana” when the user clicks on the button.
<html>
<head>
<title>alert function</title>
</head>
<Body>
<p>
</p>
</body>
</html>
©Juliet 2023
Page 4
Introduction to JavaScript 2023
Website Maintenance
Web site maintenance refers to updating and keeping your site working properly. The benefits
of website maintenance include:-
©Juliet 2023
Page 5