Web Programming Java Script-Introduction. What is Javascript? JavaScript is a scripting language using for the Web. JavaScript is a programming language.

Slides:



Advertisements
Similar presentations
17 HTML, Scripting, and Interactivity Section 17.1 Add an audio file using HTML Create a form using HTML Add text boxes using HTML Add radio buttons and.
Advertisements

Chapter 08: Adding Adding Interactivity Interactivity With With Behaviors Behaviors By Bill Bennett Associate Professor MSJC CIS MVC.
JavaScript FaaDoOEngineers.com FaaDoOEngineers.com.
The Web Warrior Guide to Web Design Technologies
JavaScript 101 Lesson 01: Writing Your First JavaScript.
JavaScript- Introduction. What it is and what it does? What it is? It is NOT Java It is NOT Server-side programming Users can see code It is a client-side.
HTML Comprehensive Concepts and Techniques Second Edition Project 8 Integrating JavaScript with HTML.
CIS101 Introduction to Computing Week 11. Agenda Your questions Copy and Paste Assignment Practice Test JavaScript: Functions and Selection Lesson 06,
JavaScript 101 Lesson 5: Introduction to Events. Lesson Topics Event driven programming Events and event handlers The onClick event handler for hyperlinks.
Introduction to JavaScript. Aim To enable you to write you first JavaScript.
1 Events Lect 8. 2 Event-driven Pages one popular feature of the Web is its interactive nature e.g., you click on buttons to make windows appear e.g.,
Javascript and the Web Whys and Hows of Javascript.
4.1 JavaScript Introduction
Introduction to JavaScript Dr. John P. Abraham University of Texas – Pan American.
 2003 Prentice Hall, Inc. All rights reserved. CHAPTER 3 JavaScript 1.
McGraw-Hill/Irwin © 2004 by The McGraw-Hill Companies, Inc. All rights reserved. Dynamic Action with Macromedia Dreamweaver MX Barry Sosinsky Valda Hilley.
SEG3210 DHTML Tutorial. DHTML DHTML is a combination of technologies used to create dynamic and interactive Web sites. –HTML - For creating text and image.
Event Handlers CS101 Introduction to Computing. Learning Goals Learn about event handlers Determine how events are useful in JavaScript Discover where.
CNIT 133 Interactive Web Pags – JavaScript and AJAX JavaScript Environment.
10 Adding Interactivity to a Web Site Section 10.1 Define scripting Summarize interactivity design guidelines Identify scripting languages Compare common.
DHTML: Dynamic HTML Internet Technology1. What is DHTML? A collection of enhancements to HTML ► To create dynamic and interactive websites Combination.
HTML. WHAT IS HTML HTML stands for Hyper Text Markup Language HTML is not a programming language, it is a markup language A markup language is a set of.
SEG3210 DHTML Tutorial. DHTML DHTML is a combination of technologies used to create dynamic and interactive Web sites. –HTML - For creating text and image.
Client Scripting1 Internet Systems Design. Client Scripting2 n “A scripting language is a programming language that is used to manipulate, customize,
Section 17.1 Add an audio file using HTML Create a form using HTML Add text boxes using HTML Add radio buttons and check boxes using HTML Add a pull-down.
What is Java Script? An extension to HTML. An extension to HTML. Allows authors to incorporate some functionality in their web pages. (without using CGI.
Lesson13. JavaScript JavaScript is an interpreted language, designed to function within a web browser. It can also be used on the server.
Extending HTML CPSC 120 Principles of Computer Science April 9, 2012.
 2003 Prentice Hall, Inc. All rights reserved. CHAPTER 3 JavaScript 1.
Client-Side Scripting JavaScript.  produced by Netscape for use within HTML Web pages.  built into all the major modern browsers. properties  lightweight,
Dynamic Web Pages & JavaScript. Dynamic Web Pages Dynamic = Change Dynamic Web Pages are web pages that change. More than just moving graphics around.
Introducing the World Wide Web Internet- a structure made up of millions of interconnected computers whose users communicate with each other and share.
1 JavaScript
Introduction to JavaScript CS101 Introduction to Computing.
1 A Balanced Introduction to Computer Science David Reed, Creighton University ©2005 Pearson Prentice Hall ISBN X Chapter 4 JavaScript and.
Sahar Mosleh California State University San MarcosPage 1 JavaScript Basic.
ECA 225 Applied Interactive Programming1 ECA 225 Applied Online Programming basics.
By Tharith Sriv. To write a web page you use: HHTML (HyperText Markup Language), AASP (Active Server Page), PPHP (HyperText Preprocessor), JJavaScript,
JavaScript Introduction.  JavaScript is a scripting language  A scripting language is a lightweight programming language  A JavaScript can be inserted.
1 CSC160 Chapter 7: Events and Event Handlers. 2 Outline Event and event handlers onClick event handler onMouseOver event handler onMouseOut event handler.
Introduction into JavaScript Java 1 JavaScript JavaScript programs run from within an HTML document The statements that make up a program in an HTML.
HTML Overview Part 5 – JavaScript 1. Scripts 2  Scripts are used to add dynamic content to a web page.  Scripts consist of a list of commands that execute.
JavaScript Challenges Answers for challenges
JavaScript Overview Developer Essentials How to Code Language Constructs The DOM concept- API, (use W3C model) Objects –properties Methods Events Applications;
Spiderman ©Marvel Comics Creating Web Pages (part 1)
Javascript Overview. What is Javascript? May be one of the most popular programming languages ever Runs in the browser, not on the server All modern browsers.
Understanding JavaScript and Coding Essentials Lesson 8.
JavaScript Introduction and Background. 2 Web languages Three formal languages HTML JavaScript CSS Three different tasks Document description Client-side.
Beginning JavaScript 4 th Edition. Chapter 1 Introduction to JavaScript and the Web.
1 CSC160 Chapter 1: Introduction to JavaScript Chapter 2: Placing JavaScript in an HTML File.
Javascript Basic Concepts Presentation By: Er. Sunny Chanday Lecturer CSE/IT RBIENT.
JavaScript and Ajax (JavaScript Environment) Week 6 Web site:
JavaScript 101 Lesson 6: Introduction to Functions.
1 JavaScript and Dynamic Web Pages Lecture 7. 2 Static vs. Dynamic Pages  A Web page uses HTML tags to identify page content and formatting information.
Using DHTML to Enhance Web Pages
JavaScript is a programming language designed for Web pages.
Nick Sims Scripting Languages.
Section 17.1 Section 17.2 Add an audio file using HTML
Web Development & Design Foundations with HTML5 7th Edition
Section 10.1 YOU WILL LEARN TO… Define scripting
DHTML Javascript Internet Technology.
Integrating JavaScript and HTML
DHTML Javascript Internet Technology.
Introduction to JavaScript
Teaching slides Chapter 6.
Tutorial 10: Programming with javascript
JavaScript Basics What is JavaScript?
JavaScript is a scripting language designed for Web pages by Netscape.
CNIT 133 Interactive Web Pags – JavaScript and AJAX
Web Programming and Design
Presentation transcript:

Web Programming Java Script-Introduction

What is Javascript? JavaScript is a scripting language using for the Web. JavaScript is a programming language used to make web pages interactive. It runs on your visitor's computer and doesn't require constant downloads from your website. Before you learn JavaScript, you need to know how to write a HTML page. You may want to learn HTML first. JavaScript is used for adding functions, and features, something like validate forms, detect browsers, dynamically change background colors, open a new window, and much more What Exactly Is JavaScript?

Need to Know No, they are two completely different computer languages. Only their names are similar. If you want to learn about Java instead, we have a whole other resource section on Java. What Do I Need to Run JavaScript? Are JavaScript and Java the Same ? JavaScript support is built right into all the major web browsers, including Internet Explorer, Firefox and Safari. Provided that the visitors to your site are using web browsers that support JavaScript (most do) and have JavaScript enabled (it is by default), then your JavaScript will run when they visit the page. Do I Need to Learn Javascript to Be Able to Use It? No. There are plenty of pre-written JavaScripts that people have made available for you to plug straight into your web page. All you need to know to be able to use such scripts is how to paste the supplied code into the required places in your web page.

Need to Know (Cont…) What Do I Need to Write JavaScript? JavaScript is an interpreted language, so no special program is required to create usable code. Any plain text editor such as Notepad (one of the Accessories that comes in Windows) is quite satisfactory for being able to write JavaScript. Can I Use HTML Instead of JavaScript? No. HTML and JavaScript are two completely different things. HTML is a markup language designed for defining static web page content. JavaScript is a programming language designed for performing dynamic tasks. Sometimes the distinction is confusing because JavaScript code can go in the same file as HTML. (More on that in a minute.)

Need to Know(Cont…) Does the Javascript Go in the Same File as the HTML? It can, but your scripts will be more easily reused on multiple pages of your site if you place them in separate files. (Using a.JS extension helps identify them as Javascript.) You then just link the JavaScript to your HTML by inserting a tag. The same JavaScript can then be added to several pages just by adding the appropriate tag into each of the pages to set up the link Applications can be as subtle as welcoming a site’s visitor with the greeting “Good morning!” when it is morning in the client computer’s time zone—even though it is dinnertime where the server is located. Example:

Entering Your First Script Eaxmple 1: This is a JavaScript example <!-- document.write("Hello World!"); //--> Hi, man!

Entering Your First Script Example 2: My First Script.highlight {font-weight: bold} Let’s Script... <!-- hide from old browsers document.write(“This browser is version “ + navigator.appVersion); document.write(“ of ” + navigator.appName + “.”); // end script hiding -->

Description document.write(), meaning display text in the current document The line of text that the script writes starts with some static text (“This browser is version”) and adds some evaluated text (the version of the browser) to it. The writing continues with more static text that includes an HTML tag (“ of ”), more evaluated text (the name of the browser application), and an HTML closing tag and the sentence’s period (“.”) the appVersion property of the navigator object

Tag positions Scripts in the Head and Body A Document //script statement(s) here... //script statement(s) here...

Tag positions Two Scripts in the Body A Document //script statement(s) here... //script statement(s) here...

Tag positions Hiding Scripts from Most Old Browsers <!-- //script statement(s) here... // -->

JavaScript Statements Virtually every line of code that sits between a... tag pair is a JavaScript statement. A statement must be in the script for a purpose. Therefore, every statement does “something” relevant to the script. The kinds of things that statements do are ✦ Define or initialize a variable ✦ Assign a value to a property or variable ✦ Change the value of a property or variable ✦ Invoke an object’s method ✦ Invoke a function routine ✦ Make a decision

When Script Statements Execute Now that you know where scripts go in a document, it’s time to look at when they run.Depending on what you need a script to do, you have four choices for determining when a script runs: ✦ While a document loads ✦ Immediately after a document loads ✦ In response to user action ✦ When called upon by other script statements The determining factor is how the script statements are positioned in a document.

While a document loads—immediate execution My First Script.highlight {font-weight: bold} Let’s Script... <!-- hide from old browsers document.write(“This browser is version “ + navigator.appVersion); document.write(“ of ” + navigator.appName + “.”); // end script hiding --> HTML Page with Immediate Script Statements

Deferred scripts The other three ways that script statements run are grouped together as what I call deferred scripts. A function defines a block of script statements summoned to run some time after those statements load into the browser. Functions are clearly visible inside a tag. Once a function is loaded into the browser (commonly in the Head portion so it loads early), it stands ready to run whenever called upon. One of the times a function is called upon to run is immediately after a page loads. The window object has an event handler called onload. Unlike most event handlers, which are triggered in response to user action (for example, clicking a button), the onload event handler fires the instant that all of the page’s components (including images, Java applets, and embedded multimedia) are loaded into the browser. The onload event handler goes in the tag.

Deferred scripts Cont…. Running a Script from the onload Event Handler An onload script <!-- function done() { alert(“The page has finished loading.”); } // --> Here is some body text. Note: When the page completes loading, the onload event handler triggers the done() function. That function (simplified for this example) displays an alert dialog box.

Deferred scripts Cont…. Running a Script from User Action An onclick script <!-- function alertUser() { alert(“Ouch!”); } // --> Here is some body text. <input type=”button” name=”oneButton” value=”Press Me!” onclick=”alertUser()”> A script that runs when a user clicks a button.

Thanks