2017, Fall Pusan National University Ki-Joune Li

Slides:



Advertisements
Similar presentations
Lecture 4: Javascript Basics Javascript is a scripting language based on pieces of C, C++, shell scripts, Pascal, Java, etc. Scripts – loosely typed C++
Advertisements

Java Script Session1 INTRODUCTION.
JavaScript Part 6. Calling JavaScript functions on an event JavaScript doesn’t have a main function like other programming languages but we can imitate.
1 CSC 551: Web Programming Spring 2004 client-side programming with JavaScript  scripts vs. programs  JavaScript vs. JScript vs. VBScript  common tasks.
1 Javascrbipt Intro Javascript (or js) is a programming language. Interpreted, not compiled. Not the same as java, but, similar. Use tags to use. Object-oriented.
1 Outline 13.1Introduction 13.2A Simple Program: Printing a Line of Text in a Web Page 13.3Another JavaScript Program: Adding Integers 13.4Memory Concepts.
 2008 Pearson Education, Inc. All rights reserved JavaScript: Introduction to Scripting.
4.1 JavaScript Introduction
JavaScript Teppo Räisänen LIIKE/OAMK HTML, CSS, JavaScript HTML defines the structure CSS defines the layout JavaScript is used for scripting It.
CNIT 133 Interactive Web Pags – JavaScript and AJAX JavaScript Environment.
JavaScript 1. What is JavaScript? JavaScript allows web authors to create dynamic pages that react to user interaction. It is an Object-based because.
1 JavaScript. 2 What’s wrong with JavaScript? A very powerful language, yet –Often hated –Browser inconsistencies –Misunderstood –Developers find it painful.
 2001 Prentice Hall, Inc. All rights reserved. 1 Chapter 7 - JavaScript: Introduction to Scripting Outline 7.1 Introduction 7.2 Simple Program: Printing.
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.
INTRODUCTION TO JAVASCRIPT AND DOM Internet Engineering Spring 2012.
Ch 6: JavaScript Introduction to scripting part 2.
1Computer Sciences Department Princess Nourah bint Abdulrahman University.
Dr. Qusai Abuein1 Internet & WWW How to program Chap.(6) JavaScript:Introduction to Scripting.
JavaScript Syntax, how to use it in a HTML document
JavaScript - Basic Concepts Prepared and Presented by Hienvinh Nguyen, Afshin Tiraie.
JavaScript Scripting language What is Scripting ? A scripting language, script language, or extension language is a programming language.
Internet & World Wide Web How to Program, 5/e © by Pearson Education, Inc. All Rights Reserved.
JavaScript. JavaScript is the programming language of HTML and the Web. Easy to learn One of the 3 languages of all developers MUST learn: 1. HTML to.
JavaScript Introduction.  JavaScript is a scripting language  A scripting language is a lightweight programming language  A JavaScript can be inserted.
4. Javascript M. Udin Harun Al Rasyid, S.Kom, Ph.D Lab Jaringan Komputer (C-307) Desain.
 2008 Pearson Education, Inc. All rights reserved JavaScript: Introduction to Scripting.
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 1 COE 201- Computer Proficiency. Introduction JavaScript scripting language ▫Originally created by Netscape ▫Facilitates disciplined approach.
Java Script About Java Script Document Object Model Incorporating JavaScript Adding JavaScript to HTML Embedding a Javascript External Scripts Javascript.
Internet & World Wide Web How to Program, 5/e © by Pearson Education, Inc. All Rights Reserved.
Chapter 7 - JavaScript: Introduction to Scripting Outline 7.1 Introduction 7.2 Simple Program: Printing a Line of Text in a Web Page 7.3 Another JavaScript.
 2008 Pearson Education, Inc. All rights reserved JavaScript: Introduction to Scripting.
Introduction to JavaScript CSc 2320 Fall 2014 Disclaimer: All words, pictures are adopted from “Simple JavaScript”by Kevin Yank and Cameron Adams and also.
JavaScript. JavaScript Introduction JavaScript is the world's most popular programming language. It is the language for HTML and the web, for servers,
Document Object Model Nasrullah. DOM When a page is loaded,browser creates a Document Object Model of the Page.
This is our seminar JavaScript And DOM This is our seminar JavaScript And DOM.
Introduction to Javascript. What is javascript?  The most popular web scripting language in the world  Used to produce rich thin client web applications.
CGS 3066: Web Programming and Design Spring 2016 Introduction to JavaScript.
JavaScript and Ajax (JavaScript Environment) Week 6 Web site:
JavaScript Events. Understanding Events Events add interactivity between the web page and the user Events add interactivity between the web page and the.
INTERNET APPLICATIONS CPIT405 JavaScript Instructor: Rasha AlOmari
 2001 Prentice Hall, Inc. All rights reserved. Outline 1 JavaScript.
Client-side (JavaScript) Validation. Associating a function with a click event – Part 1 Use the input tag’s onclick attribute to associate a function.
CGS 3066: Web Programming and Design Spring 2017
Build in Objects In JavaScript, almost "everything" is an object.
Web Basics: HTML/CSS/JavaScript What are they?
Week 3: Introduction to Javascript
CIIT-Human Computer Interaction-CSC456-Fall-2015-Mr
Chapter 6 JavaScript: Introduction to Scripting
CGS 3066: Web Programming and Design Spring 2017
JavaScript Event Handling.
Intro to JavaScript CS 1150 Spring 2017.
Barb Ericson Georgia Institute of Technology May 2006
WEB APPLICATION PROGRAMMING
Introduction to Scripting
4. Javascript Pemrograman Web I Program Studi Teknik Informatika
JavaScript an introduction.
Web Systems Development (CSC-215)
DHTML Javascript Internet Technology.
Understanding JavaScript and Coding Essentials
DHTML Javascript Internet Technology.
Web Programming Language
Unit 6 part 3 Test Javascript Test.
Introduction to HTML5.
Pertemuan 1b
Tutorial 10: Programming with javascript
JavaScript – Functions
JavaScript: Introduction to Scripting
JavaScript.
CNIT 133 Interactive Web Pags – JavaScript and AJAX
Presentation transcript:

2017, Fall Pusan National University Ki-Joune Li JavaScript - Basic 2017, Fall Pusan National University Ki-Joune Li

JavaScript JavaScript is one of the 3 languages all web developers must learn: HTML to define the content of web pages CSS to specify the layout of web pages JavaScript to program the behavior of web pages JavaScript is like any other high level language like Java Almost similar syntax But different semantics Script Language: need no compiling to make executable machine code

JavaScript - Example First example: JavaScript can insert HTML contents <!DOCTYPE html> <html> <head></head> <body> <h1>Welcome to JavaScript</h1> <script type="text/javascript"> document.writeln("<p>Inserted Line</p>"); </script> </body> </html> Method of document object

JavaScript - Example Second example: JavaScript can change HTML contents via getElementById(): to find an HTML element (with id="demo") and changes the element content (innerHTML) Example Third example: JavaScript can change HTML attributes This example changes an HTML image by changing the src (source) attribute of an <img> tag:

JavaScript - Example Fourth example: JavaScript can receive user input <!DOCTYPE html> <html> <head></head> <body> <script type="text/javascript"> var name; name=window.prompt("Please enter your name"); document.writeln("<p>Hello "+name+", Welcome to JS programming</p>"); </script> </body> </html> Method of window object

JavaScript – Parsing a value Fifth example: JavaScript can parse given type from user input <!DOCTYPE html> <html> <head></head> <body> <script type="text/javascript"> var firstNumber, secondNumber; var number1, number2, sum; firstNumber=window.prompt("Please enter first number"); number1=parseInt(firstNumber); secondNumber=window.prompt("Please enter scond number"); number2=parseInt(secondNumber); sum=number1+number2; document.writeln("<p>The sum is "+sum+"</p>"); </script> </body> </html> Function or method of global object

JavaScript – Variables JavaScript does not require any type declaration before using it. Loosely typed language: cf. C/C++ Language Automatic conversion of type  number1 becomes an integer var number 1; firstNumber=window.prompt("Please enter a number"); number1=parseInt(firstNumber); var number 1; firstNumber=window.prompt("Please enter a number"); number1=parseFloat(firstNumber);

JavaScript – Variables Example var length = 16;                               // Number var lastName = "Johnson";                      // String var x = {firstName:"John", lastName:"Doe"};    // Object <!DOCTYPE html> <html> <body> <script type="text/javascript"> var x=16+"volvo"; document.writeln(x); </script> </body> </html> <!DOCTYPE html> <html> <body> <script type="text/javascript"> var x=16+4+"volvo"; document.writeln(x); </script> </body> </html>

JavaScript – Operators JavaScript provides almost the same operators of Java +, /, *, -, % (reminder), +=, ++, -- <, <=, >, >=, ==, != except ===, !== With the same operator precedence <!DOCTYPE html> <html> <head></head> <body> <script type="text/javascript"> var name; var now=new Date(); var hour=now.getHours(); if (hour<12) document.writeln("<p> Good Morning</p>"); else if (hour>=12) { hour-=12; if(hour<6) document.writeln("<p> Good Afternoon</p>"); else document.writeln("<p> Good Evening</p>"); } </script> </body> </html>

JavaScript – Control Statements JavaScript provides almost the same control statements if, else, while, do while, for, break, continue <!DOCTYPE html> <html> <head></head> <body> <script type="text/javascript"> var amount, principal=1000.00, rate=0.02; document.writeln("<table> <caption>Calculating Interest</caption>"); document.writeln("<thead><tr><th>Year</th><th>Amount </th></tr></thead>"); document.writeln("<tbody>"); for(var year=1;year<=10;++year) { amount=principal*Math.pow(1.0+rate, year); document.writeln("<tr><td>"+year+"</td><td>"+amount.toFixed(2)); document.writeln("</td></tr>"); } document.writeln("</tbody></table>"); </script> </body>