Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
6 views

Introduction to JavaScript and the Web

Uploaded by

ptolentino697
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views

Introduction to JavaScript and the Web

Uploaded by

ptolentino697
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 15

INTRODUCTION TO

JAVASCRIPT AND THE


WEB
What is JavaScript?
JavaScript
- is a sort of computer language.
- JavaScript language first became
available in the web browser Netscape
Navigator 2.
- a scripting language designed
primarily for adding interactivity to
web pages & creating web applications
Computer Language –
a series of instructions that instruct the computer to do something.
That something can be a wide variety of things, including displaying
text, moving an image, or asking the user information. The instructions,
or what is term code are processed from the top line downwards.
Processed simply means that the computer looks at the code we’re
written, work out what action we want taken, and then takes that
action
Code - is a generic term for program instruction.
Running or Executing - the actual act of processing the code.

Debug or Debugging - the process of tracing error.


Algorithms - any set of instruction that can be followed to
carry out a particular tasks.
High Level Language - a language usually cannot directly
understand by a computer.
2 General Senses

1. Human-Readable Source Code the


instructions written by the programmer in a
programming language.
2. Executable Machine Code the instructions of
a program that were converted from source
code to the instructions that the computer
can understand.
Using natural English, let’s see what
instructions, or code, we might write to
make a cup of coffee.
1. Put coffee in cup
2. Fill kettle with water
3. Put kettle on to boil
4. Has the kettle boiled? If so, then pour water
into cup, otherwise continue to wait
5. Drink coffee.
JavaScript - is a interpreted language, rather than a compiled
language.
Interpreted language - a language that is interpreted. - an
interpreted language is one where the instructions are
converted from what you have written into machine code as
the program is being run.
Interpreter - a program that translates and then executes
each statement in a program.
Compiled language - a language that is translated into
Machine code prior to any execution. The program code is
converted to machine code before it’s actually run, and this
conversion has to be done once.
Compiler - a program that translates all the source code of a
program written in high-level language into object code prior to
execution of the program.
JavaScript and the Web
If you want your JavaScript code run’s inside a web
page into a browser. All we need to create these web
pages.
Tools to create a JavaScript Program
1. Text editor (Ex. Windows Notepad)-tools needed to
create JavaScript web.
2. Web Browser (such as Netscape navigator or internet
Explorer) use to view on pages.
Internet - one big network connecting computers together.

Websites - a special service provided by particular


computers on the internet.

HTTP (HyperText Transfer Protocol) - special communication


protocol.

Client - the computer running the web browser that makes


the request.

HTML (HyperText Mark-Up Language) - set of special codes


that embed in text to add formatting and linking
information.
What can JavaScript do?
The most common use of JavaScript is
interacting with your users, getting information
from them and validating their actions. For
example, we wanted to put a drop-down menu
on the page so that users can choose where they
want to go to on our website. The drop-down
menu might be plain old HTML, but it needs
JavaScript behind it to actually do something
with the user’s input.
JavaScript can also be used for various “tricks”.
You can also use JavaScript for calculations.
The <SCRIPT> Tag and Your First Simple JavaScript
Program
Inserting JavaScript in a web page is much like
inserting any other HTML content; we use tags to
mark out the start and end of our script code.
The tag we use to do this is the <SCRIPT> tag. This
tells the browser that the following chunk of text,
bounded by the closing </SCRIPT> tag, is not HTML to
be displayed, but rather script code to be
processed
Script block
- the chunk of code surrounded by the tags.
Script tag
- is used to marked out the start and end of our
script code
When the browser spots <SCRIPT> tags, instead of trying to display the
contained text to the user, it uses the browser’s built in JavaScript
interpreter to run the code’s instructions.
We can put the <SCRIPT> tags inside the header (between the <HEAD>
and </HEAD> tags), or inside the body (between the <BODY> and
</BODY> tags) of the HTML page. However, we can’t put them outside
these areas, for example before the <HTML> tag or after the </HTML>
tag since anything outside these areas is not considered by the browser
to be part of the web page and is ignored.

The <SCRIPT> tags has a number of attributes, but the most important
one for us is the LANGUAGE attributes. JavaScript is not the only scripting
language available, and different scripting languages need to be
processed in different ways. We need to tell the browser which scripting
language to expect, so that it knows how to process it
Opening Script Tag:
<SCRIPT LANGUAGE = “JavaScript”>
Sample Program1: Sample Program2:
<HTML> <HTML>
<BODY BGCOLOR="WHITE">
<BODY <P>Paragraph 1 </P>
BGCOLOR="WHITE"> <SCRIPT LANGUAGE="JavaScript">
//Script block 1
<P>Paragraph 1 </P> alert("First Script Block");
<SCRIPT </SCRIPT>
LANGUAGE="JavaScript" <P>Paragraph 2 </P>
<SCRIPT LANGUAGE="JavaScript">
> //Script block 2
document.bgColor = document.bgColor = "RED";
alert("Second Script Block");
"RED"; </SCRIPT>
</SCRIPT> <P>Paragraph 3 </P>
</BODY> </BODY>
</HTML
</HTML>
alert( ) functions enables us to alert or inform the user
about something by displaying a message box.

Functions – is a piece of code use to do certain tasks. It


takes some information, processes it, and gives you a result.

Function Parameter – the message to be given in the


message box, specified inside the parentheses of the alert( )
function

Statement – every line of code between the<SCRIPT> and


</SCRIPT> .

Parsing – the process when the browser loads in the web


page.

; (semicolon) – used to indicate the end of line of code.


The message box that’s displayed by the alert( ) function is MODAL;
it is means that the message box won’t go away until the user
closes it by clicking the OK button.
The important problem raised by this example is the difference
between setting properties of the page such as background color,
via HTML and doing the same thing using JavaScript. The method of
setting properties using HTML is STATIC, a value can be set only
once and never changed again using HTML. Setting properties using
JavaScript enables us to dynamically change their values. By
DYNAMIC it’s simply mean something that can be changed and
whose value or appearance is not
set in stone.

You might also like