View
216
Download
1
Category
Preview:
Citation preview
Dynamic Web Pages & JavaScript
Dynamic Web Pages
Dynamic = ChangeDynamic Web Pages are web pages that
change.More than just moving graphics around.
Static = Stays the Same
Programming Language
A language for specifying instructions that a computer can execute.
Each STATEMENT in a language specifies a different thing for the computer to do.
Programming Languanges
There are lots of different languagesC++HTMLJava
Adding Dynamic Content to Your Website
Easiest Way to add dynamic content to your website? JavaScript!Derived from Java (a programming
language) to add dynamic content to a web site.
How? Embed JavaScript statements into the HTML
code of our website!
Don’t be Scurred
JavaScript is designed to be simpleLet’s take a look…
A simple JavaScript statement
<script type=“text/javascript”>firstName = prompt(“What’s your name?”, “”)
Document.write(“Hello “ + firstName + “, welcome to my web page.”)
</script>
Simple Dynamic Page
Here’s a simple Web page with dynamic content note: dynamic content can be mixed with static HTML content
it demonstrates two types of JavaScript statements an assignment statement that asks the user for input and stores that input a write statement that writes text into the HTML page
Simple Dynamic Page
JavaScript is a simple programming language for making dynamic Web pages, i.e., pages that can interact with the user and vary each time they are loaded.
JavaScript code can be embedded inside the BODY of an HTML document, enclosed by the tags <SCRIPT LANGUAGE="JavaScript"> and </SCRIPT>.
The simplest JavaScript statement is a document.write statement, which displays text in the Web page. The displayed text can be formatted using HTML tags.
The JavaScript function prompt can be used to read a value from the user via a dialog box. The function takes two inputs, a prompt message and a default value, and returns the value entered by the user (or the default value if they don't enter anything).
Old MacDonald
this page prompts the user for the animal and sound ("cow" and "moo", by default), then displays a verse using those values <br /> tags are embedded to break the output onto separate lines
Old MacDonald
A variable is a name that is used to represent some unspecified value in an expression.
In JavaScript, a variable name can be any sequence of letters, digits, and underscores starting with a letter. Since JavaScript is case-sensitive, capitalization matters.
Each variable stores its value.
A value is assigned to a variable
What’s Next?
FUN WITH JavaScript AssignmentExplore on your ownSearch for JavaScript on the webMany Many Sites that give away code…Paste this into your HTML tab of
FrontPage.
Recommended