Introduction to.

Slides:



Advertisements
Similar presentations
Intro to Javascript CS Client Side Scripting CS380 2.
Advertisements

Chapter 08: Adding Adding Interactivity Interactivity With With Behaviors Behaviors By Bill Bennett Associate Professor MSJC CIS MVC.
Sue Wills July Objects The JavaScript language is completely centered around objects, and because of this, it is known as an Object Oriented Programming.
JavaScript FaaDoOEngineers.com FaaDoOEngineers.com.
Java Script Session1 INTRODUCTION.
Lesson 12- Unit L Programming Web Pages with JavaScript.
The Web Warrior Guide to Web Design Technologies
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.
JavaScript CMPT 281. Outline Introduction to JavaScript Resources What is JavaScript? JavaScript in web pages.
Javascript and the Web Whys and Hows of Javascript.
4.1 JavaScript Introduction
1 CS 3870/CS 5870 Static and Dynamic Web Pages ASP.NET and IIS.
JavaScript Teppo Räisänen LIIKE/OAMK HTML, CSS, JavaScript HTML defines the structure CSS defines the layout JavaScript is used for scripting It.
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.
CSC 330 E-Commerce Teacher Ahmed Mumtaz Mustehsan Ahmed Mumtaz Mustehsan GM-IT CIIT Islamabad GM-IT CIIT Islamabad CIIT Virtual Campus, CIIT COMSATS Institute.
SEG3210 DHTML Tutorial. DHTML DHTML is a combination of technologies used to create dynamic and interactive Web sites. –HTML - For creating text and image.
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.
Javascript. Outline Introduction Fundamental of JavaScript Javascript events management DOM and Dynamic HTML (DHTML)
Client Side Programming with JavaScript Why use client side programming? Web sides built on CGI programs can rapidly become overly complicated to maintain,
INTRODUCTION TO JAVASCRIPT AND DOM Internet Engineering Spring 2012.
Extending HTML CPSC 120 Principles of Computer Science April 9, 2012.
Client-Side Scripting JavaScript.  produced by Netscape for use within HTML Web pages.  built into all the major modern browsers. properties  lightweight,
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
Dr. Qusai Abuein1 Internet & WWW How to program Chap.(6) JavaScript:Introduction to Scripting.
JavaScript Syntax, how to use it in a HTML document
Overview of Form and Javascript fundamentals. Brief matching exercise 1. This is the software that allows a user to access and view HTML documents 2.
JavaScript Scripting language What is Scripting ? A scripting language, script language, or extension language is a programming language.
JavaScript Defined DOM (Document Object Model) General Syntax Body vs. Head Variables Math & Logic Selection Functions & Events Loops Animation Getting.
 Web pages originally static  Page is delivered exactly as stored on server  Same information displayed for all users, from all contexts  Dynamic.
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.
Document Object Model Nasrullah. DOM When a page is loaded,browser creates a Document Object Model of the Page.
JavaScript Introduction and Background. 2 Web languages Three formal languages HTML JavaScript CSS Three different tasks Document description Client-side.
Web Programming Java Script-Introduction. What is Javascript? JavaScript is a scripting language using for the Web. JavaScript is a programming language.
JavaScript for Interactive Web Pages
Applied Component I Unit II Introduction of java-script
Week 3: Introduction to Javascript
CIIT-Human Computer Interaction-CSC456-Fall-2015-Mr
Tutorial 10 Programming with JavaScript
Week 4: Introduction to Javascript
JavaScript is a programming language designed for Web pages.
Intro to JavaScript CS 1150 Spring 2017.
Section 17.1 Section 17.2 Add an audio file using HTML
Web Development & Design Foundations with HTML5 7th Edition
4. Javascript Pemrograman Web I Program Studi Teknik Informatika
JavaScript.
Introduction to JavaScript
JavaScript Introduction
JavaScript an introduction.
DHTML Javascript Internet Technology.
A second look at JavaScript
DHTML Javascript Internet Technology.
Introduction to JavaScript
Tutorial 10 Programming with JavaScript
Javascript and JQuery SRM DSC.
Introduction to DHTML, the DOM, JS review
Introduction to JavaScript
JavaScript CS 4640 Programming Languages for Web Applications
Tutorial 10: Programming with javascript
JavaScript Basics What is JavaScript?
JavaScript is a scripting language designed for Web pages by Netscape.
Introduction to Programming and JavaScript
JavaScript: Introduction to Scripting
Introduction to JavaScript
Web Programming and Design
Web Programming and Design
Presentation transcript:

Introduction to

PHP/MYSQL/ UNIT- 2 LAB 3-JAVASCRIPT/ INDRANI.B, AP/SCD Client Side Scripting 7/20/2017 PHP/MYSQL/ UNIT- 2 LAB 3-JAVASCRIPT/ INDRANI.B, AP/SCD

Why we use client-side programming? PHP already allows us to create dynamic web pages. client-side scripting (JavaScript) benefits: usability efficiency event-driven 7/20/2017 PHP/MYSQL/ UNIT- 2 LAB 3-JAVASCRIPT/ INDRANI.B, AP/SCD

Why use client-side programming? server-side programming (PHP) benefits: security compatibility power 7/20/2017 PHP/MYSQL/ UNIT- 2 LAB 3-JAVASCRIPT/ INDRANI.B, AP/SCD

PHP/MYSQL/ UNIT- 2 LAB 3-JAVASCRIPT/ INDRANI.B, AP/SCD What is Javascript? a lightweight programming language ("scripting language") used to make web pages interactive insert dynamic text into HTML (ex: user name) react to events (ex: page load user click) get information about a user's computer (ex: browser type) perform calculations on user's computer (ex: form validation) 7/20/2017 PHP/MYSQL/ UNIT- 2 LAB 3-JAVASCRIPT/ INDRANI.B, AP/SCD

PHP/MYSQL/ UNIT- 2 LAB 3-JAVASCRIPT/ INDRANI.B, AP/SCD Javascript vs Java Interpreted, not compiled more relaxed syntax and rules fewer and "looser" data types variables don't need to be declared errors often silent (few exceptions) key construct is the function rather than the class "first-class" functions are used in many situations contained within a web page and integrates with its HTML/CSS content 7/20/2017 PHP/MYSQL/ UNIT- 2 LAB 3-JAVASCRIPT/ INDRANI.B, AP/SCD

PHP/MYSQL/ UNIT- 2 LAB 3-JAVASCRIPT/ INDRANI.B, AP/SCD Javascript vs Java + = 7/20/2017 PHP/MYSQL/ UNIT- 2 LAB 3-JAVASCRIPT/ INDRANI.B, AP/SCD

PHP/MYSQL/ UNIT- 2 LAB 3-JAVASCRIPT/ INDRANI.B, AP/SCD JavaScript vs. PHP similarities: both are interpreted, not compiled both are relaxed about syntax, rules, and types both are case-sensitive both have built-in regular expressions for powerful text processing 7/20/2017 PHP/MYSQL/ UNIT- 2 LAB 3-JAVASCRIPT/ INDRANI.B, AP/SCD

PHP/MYSQL/ UNIT- 2 LAB 3-JAVASCRIPT/ INDRANI.B, AP/SCD JavaScript vs. PHP Differences: JS is more object-oriented: noun.verb(), less procedural: verb(noun) JS focuses on user interfaces and interacting with a document; PHP is geared toward HTML output and file/form processing JS code runs on the client's browser; PHP code runs on the web server JS <3 7/20/2017 PHP/MYSQL/ UNIT- 2 LAB 3-JAVASCRIPT/ INDRANI.B, AP/SCD

Linking to a JavaScript file: script <script src="filename" type="text/javascript"></script> script tag should be placed in HTML page's head script code is stored in a separate .js file JS code can be placed directly in the HTML file's body or head (like CSS) 7/20/2017 PHP/MYSQL/ UNIT- 2 LAB 3-JAVASCRIPT/ INDRANI.B, AP/SCD

Event-driven programming split breaks apart a string into an array using a delimiter can also be used with regular expressions (seen later) join merges an array into a single string, placing a delimiter between them 7/20/2017 PHP/MYSQL/ UNIT- 2 LAB 3-JAVASCRIPT/ INDRANI.B, AP/SCD

A JavaScript statement: alert alert("IE6 detected. Suck-mode enabled."); JS a JS command that pops up a dialog box with a message 7/20/2017 PHP/MYSQL/ UNIT- 2 LAB 3-JAVASCRIPT/ INDRANI.B, AP/SCD

Event-driven programming JavaScript programs instead wait for user actions called events and respond to them event-driven programming: writing programs driven by user events 7/20/2017 PHP/MYSQL/ UNIT- 2 LAB 3-JAVASCRIPT/ INDRANI.B, AP/SCD

PHP/MYSQL/ UNIT- 2 LAB 3-JAVASCRIPT/ INDRANI.B, AP/SCD Buttons <button>Click me!</button> HTML button's text appears inside tag; can also contain images To make a responsive button or other UI control: choose the control (e.g. button) and event (e.g. mouse 1. click) of interest write a JavaScript function to run when the event occurs attach the function to the event on the control Reset is not working here! Debug! test1.html 7/20/2017 PHP/MYSQL/ UNIT- 2 LAB 3-JAVASCRIPT/ INDRANI.B, AP/SCD

PHP/MYSQL/ UNIT- 2 LAB 3-JAVASCRIPT/ INDRANI.B, AP/SCD JavaScript functions function name() { statement ; ... } JS function myFunction() { alert("Hello!"); alert("How are you?"); } JS the above could be the contents of example.js linked to our HTML page statements placed into functions can be evaluated in response to user events 7/20/2017 PHP/MYSQL/ UNIT- 2 LAB 3-JAVASCRIPT/ INDRANI.B, AP/SCD

PHP/MYSQL/ UNIT- 2 LAB 3-JAVASCRIPT/ INDRANI.B, AP/SCD Event handlers <element attributes onclick="function();">... <button onclick="myFunction();">Click me!</button> JavaScript functions can be set as event handlers when you interact with the element, the function will execute On click is just one of many event HTML attributes we'll use. 7/20/2017 PHP/MYSQL/ UNIT- 2 LAB 3-JAVASCRIPT/ INDRANI.B, AP/SCD

Document Object Model (DOM) Most JS code manipulates elements on an HTML page We can examine elements' state e.g. see whether a box is checked We can change state e.g. insert some new text into a div We can change styles e.g. make a paragraph red 7/20/2017 PHP/MYSQL/ UNIT- 2 LAB 3-JAVASCRIPT/ INDRANI.B, AP/SCD

Accessing elements: document.getElementById Document.getElementById returns the DOM object for an element with a given id Can change the text inside most elements by setting the innerHTML property Can change the text in form controls by setting the value property 7/20/2017 PHP/MYSQL/ UNIT- 2 LAB 3-JAVASCRIPT/ INDRANI.B, AP/SCD

Changing element style: element.style Attribute Property or style object color padding background-color backgroundColor border-top-width borderTopWidth Font size fontSize Font famiy fontFamily 7/20/2017 PHP/MYSQL/ UNIT- 2 LAB 3-JAVASCRIPT/ INDRANI.B, AP/SCD

Thank you