Sahar Mosleh California State University San MarcosPage 1 JavaScript Basic.

Slides:



Advertisements
Similar presentations
1 What is JavaScript? JavaScript was designed to add interactivity to HTML pages JavaScript is a scripting language A scripting language is a lightweight.
Advertisements

Essentials for Design JavaScript Level One Michael Brooks
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.
Tutorial 10 Programming with JavaScript
Web Page Behavior IS 373—Web Standards Todd Will.
JavaScript 101 Lesson 5: Introduction to Events. Lesson Topics Event driven programming Events and event handlers The onClick event handler for hyperlinks.
2012 •••••••••••••••••••••••••••••••••• Summer WorkShop Mostafa Badr
Introduction to JavaScript. Aim To enable you to write you first JavaScript.
Introduction to scripting
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.
CS346 - Javascript 1, 21 Module 1 Introduction to JavaScript CS346.
JavaScript, Fifth Edition Chapter 1 Introduction to JavaScript.
JavaScript Defined DOM (Document Object Model) General Syntax Body vs. Head Variables Math & Logic Selection Functions & Events Loops Animation Getting.
SEG3210 DHTML Tutorial. DHTML DHTML is a combination of technologies used to create dynamic and interactive Web sites. –HTML - For creating text and image.
Bridges To Computing General Information: This document was created for use in the "Bridges to Computing" project of Brooklyn College. You are invited.
Javascript Languages By Rapee kamoltalapisek ID:
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.
INTRODUCTION TO JAVASCRIPT AND DOM Internet Engineering Spring 2012.
1 JavaScript in Context. Server-Side Programming.
Tutorial 10 Programming with JavaScript. XP Objectives Learn the history of JavaScript Create a script element Understand basic JavaScript syntax Write.
Tutorial 10 Programming with JavaScript
Done by: Hanadi Muhsen1 Tutorial 1.  Learn the history of JavaScript  Create a script element  Write text to a Web page with JavaScript  Understand.
Extending HTML CPSC 120 Principles of Computer Science April 9, 2012.
 HTML is hypertext markup language. It is a way for people to display their information with more complex pictures and text displays. Before HTML, messages.
Introduction.  The scripting language most often used for client-side web development.  Influenced by many programming languages, easier for nonprogrammers.
JavaScript - A Web Script Language Fred Durao
1 JavaScript
JavaScript Syntax, how to use it in a HTML document
An Introduction to JavaScript By: John Coliton Tuesday, November 10, 1998 Center for Teaching and Learning.
JavaScript Scripting language What is Scripting ? A scripting language, script language, or extension language is a programming language.
1 A Balanced Introduction to Computer Science David Reed, Creighton University ©2005 Pearson Prentice Hall ISBN X Chapter 4 JavaScript and.
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.
COMP403 Web Design JAVA SCRİPTS Tolgay KARANFİLLER.
4. Javascript M. Udin Harun Al Rasyid, S.Kom, Ph.D Lab Jaringan Komputer (C-307) Desain.
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 Defined DOM (Document Object Model) General Syntax Body vs. Head Variables Math & Logic Selection Functions & Events Loops Animation Getting.
Pertemuan 5 IT133 Pengembangan Web JavaScript. What is JavaScript? JavaScript was designed to add interactivity to HTML pages JavaScript is a scripting.
CIS 3.5 Lecture 2.3 "Introduction to JavaScript".
JavaScript 101 Introduction to Programming. Topics What is programming? The common elements found in most programming languages Introduction to JavaScript.
JavaScript. JavaScript Introduction JavaScript is the world's most popular programming language. It is the language for HTML and the web, for servers,
Tutorial 10 Programming with JavaScript. 2New Perspectives on HTML, XHTML, and XML, Comprehensive, 3rd Edition Objectives Learn the history of JavaScript.
Beginning JavaScript 4 th Edition. Chapter 1 Introduction to JavaScript and the Web.
JavaScript Events Java 4 Understanding Events Events add interactivity between the web page and the user You can think of an event as a trigger that.
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.
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.
JavaScript and AJAX 2nd Edition Tutorial 1 Programming with JavaScript.
1 Agenda  Unit 7: Introduction to Programming Using JavaScript T. Jumana Abu Shmais – AOU - Riyadh.
Web Programming Java Script-Introduction. What is Javascript? JavaScript is a scripting language using for the Web. JavaScript is a programming language.
Brief Look InTo JavaScript Dr. Thomas Hicks Computer Science Department Trinity University.
Tutorial 10 Programming with JavaScript
Section 17.1 Section 17.2 Add an audio file using HTML
4. Javascript Pemrograman Web I Program Studi Teknik Informatika
JavaScript.
WEB PROGRAMMING JavaScript.
CS105 Introduction to Computer Concepts
Tutorial 10: Programming with javascript
Web Programming– UFCFB Lecture 13
CS105 Introduction to Computer Concepts JavaScript
Presentation transcript:

Sahar Mosleh California State University San MarcosPage 1 JavaScript Basic

Sahar Mosleh California State University San MarcosPage 2 What is JavaScript? JavaScript was designed to add interactivity to HTML pages. A JavaScript consists of lines of executable computer code A JavaScript is usually embedded directly into HTML pages JavaScript is an interpreted language (means that scripts execute without preliminary compilation) Everyone can use JavaScript without other computer language background.

Sahar Mosleh California State University San MarcosPage 3 Are Java and JavaScript the Same? NO! Java and JavaScript are two completely different languages in both concept and design! Java (developed by Sun Microsystems) is a powerful and much more complex programming language - in the same category as C and C++.

Sahar Mosleh California State University San MarcosPage 4 What can a JavaScript Do? JavaScript gives HTML designers a programming tool - HTML authors are normally not programmers, but JavaScript is a scripting language with a very simple syntax! Almost anyone can put small “Scripts" of code into their HTML pages. JavaScript can put dynamic text into an HTML page – for example the drop down menu on a web site may be old HTML code behind it but to interact with user’s input is the job of java script code. JavaScript can also used for various tricks- for example you can switch image in a page for a different one when the user rolls her mouse over it.

Sahar Mosleh California State University San MarcosPage 5 How to Put a JavaScript Into an HTML Page document.write("Hello World!") The code above will produce this output on an HTML page: Hello World!

Sahar Mosleh California State University San MarcosPage 6 Example Explained To insert a JavaScript into an HTML page, we use the tag (also use the type attribute to define the scripting language). So, the and tells where the JavaScript starts and ends:...

Sahar Mosleh California State University San MarcosPage 7 The word document.write is a standard JavaScript command for writing output to a page. By entering the document.write command between the and tags, the browser will recognize it as a JavaScript command and execute the code line. In this case the browser will write Hello World! to the page: document.write("Hello World!") Note: If we had not entered the tag, the browser would have treated the document.write("Hello World!") command as pure text, and just write the entire line on the page.

Sahar Mosleh California State University San MarcosPage 8 Another example: Paragraph 1 document.bgColor = "RED";

Sahar Mosleh California State University San MarcosPage 9 Example Explained is a HTML code to set the background color to white. To insert a JavaScript into an HTML page, we use the to start the JavaScript code Document.bgcolor = “ RED”; set the background to red. to end the JavaScript code

Sahar Mosleh California State University San MarcosPage 10

Sahar Mosleh California State University San MarcosPage 11 Ending Statements With a Semicolon? With traditional programming languages, like C++ and Java, each code statement has to end with a semicolon. Many programmers continue this habit when writing JavaScript, but in general, semicolons are optional! However, semicolons are required if you want to put more than one statement on a single line.

Sahar Mosleh California State University San MarcosPage 12 Try It Out Paragraph 1 // Script block 1 alert("First Script Block"); Paragraph 2 // Script block 2 document.bgColor = "RED"; alert("Second Script Block"); Paragraph 3

Sahar Mosleh California State University San MarcosPage 13 How Does it work? The first part of the page is the same as our earlier example. The background is set to white and paragraph 1 is written. Paragraph 1 The first new section in the first script block: // Script block 1 alert("First Script Block"); // Script block 1 is just a comment, browser ignores anything after //

Sahar Mosleh California State University San MarcosPage 14 alert("First Script Block"); The alert function enable us to alert or inform the user about something, by displaying a message box. The message to be given in the message box is specified inside the parenthesis of the alert() function and is known as the functions’ parameter.

Sahar Mosleh California State University San MarcosPage 15 once you click OK, the browser carries on parsing down the page through the following lines: // Script block 2 document.bgColor = "RED"; alert("Second Script Block");

Sahar Mosleh California State University San MarcosPage 16

Sahar Mosleh California State University San MarcosPage 17 The second paragraph is displayed and the second block of JavaScript is run. First line is comment Second line is changing the background color. The third line is the alert function When we close the message box, the browser moves on to the next lines of the code in the page, displaying the third paragraph.

Sahar Mosleh California State University San MarcosPage 18

Sahar Mosleh California State University San MarcosPage 19 We have seen in the preceding example that by using JavaScript we can change the background color of the page by using BGCLOR property of document. We are able to use this property with both internet explorer and Netscape browsers. However for other property and functions this is not true. the material In this course is going to be compatible with internet explorer and Netscape browsers version 4 and above. Over the course we will be developing part of a web-based application, namely Trivia Quiz that works with both Netscape and explorer 4.0. We mainly later on in the course focus on the property and the functions that works with the Explorer 6.0 (new internet explorer)