JavaScript ICW: Lecture 11 Tom Chothia. Last Lecture URLs Threads, to make a process run in parallel: Make it extend Thread Give it a run method Call.

Slides:



Advertisements
Similar presentations
JavaScript and AJAX Jonathan Foss University of Warwick
Advertisements

JavaScript FaaDoOEngineers.com FaaDoOEngineers.com.
Java Script Session1 INTRODUCTION.
1 CSC 551: Web Programming Spring 2004 client-side programming with JavaScript  scripts vs. programs  JavaScript vs. JScript vs. VBScript  common tasks.
The Web Warrior Guide to Web Design Technologies
© Anselm SpoerriInfo + Web Tech Course Information Technologies Info + Web Tech Course Anselm Spoerri PhD (MIT) Rutgers University
Server-Side vs. Client-Side Scripting Languages
6/10/2015Cookies1 What are Cookies? 6/10/2015Cookies2 How did they do that?
XP Browser and Basics1. XP Browser and Basics2 Learn about Web browser software and Web pages The Web is a collection of files that reside.
1 The World Wide Web. 2  Web Fundamentals  Pages are defined by the Hypertext Markup Language (HTML) and contain text, graphics, audio, video and software.
Browser and Basics Tutorial 1. Learn about Web browser software and Web pages The Web is a collection of files that reside on computers, called.
2012 •••••••••••••••••••••••••••••••••• Summer WorkShop Mostafa Badr
Introduction to JavaScript. Aim To enable you to write you first JavaScript.
1 CS428 Web Engineering Lecture 18 Introduction (PHP - I)
McGraw-Hill/Irwin © 2004 by The McGraw-Hill Companies, Inc. All rights reserved. Beginning Active Server Pages Barry Sosinsky Valda Hilley Programming.
Client-Side programming with JavaScript 3
Javascript and the Web Whys and Hows of Javascript.
4.1 JavaScript Introduction
FALL 2005CSI 4118 – UNIVERSITY OF OTTAWA1 Part 4 Web technologies: HTTP, CGI, PHP,Java applets)
Introduction to JavaScript Dr. John P. Abraham University of Texas – Pan American.
Comp2513 Forms and CGI Server Applications Daniel L. Silver, Ph.D.
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.
XP New Perspectives on Browser and Basics Tutorial 1 1 Browser and Basics Tutorial 1.
Bridges To Computing General Information: This document was created for use in the "Bridges to Computing" project of Brooklyn College. You are invited.
WEEK 3 AND 4 USING CLIENT-SIDE SCRIPTS TO ENHANCE WEB APPLICATIONS.
Unobtrusive JavaScript
Client Scripting1 Internet Systems Design. Client Scripting2 n “A scripting language is a programming language that is used to manipulate, customize,
Microsoft Internet Explorer and the Internet Using Microsoft Explorer 5.
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.
Using Client-Side Scripts to Enhance Web Applications 1.
An Introduction to JavaScript Summarized from Chapter 6 of “Web Programming: Building Internet Applications”, 3 rd Edition.
Introduction to JavaScript 41 Introduction to Programming the WWW I CMSC Winter 2004 Lecture 17.
Mark Dixon 1 03 – Passing Data between pages: Forms, Sessions, & Query Strings.
XP Tutorial 6 New Perspectives on JavaScript, Comprehensive1 Working with Windows and Frames Enhancing a Web Site with Interactive Windows.
JavaScript - A Web Script Language Fred Durao
JS Basics 1 Lecture JavaScript - Basics. JS Basics 2 What is JavaScript JavaScript is a “simple”, interpreted, programming language with elementary object-
Intro to JavaScript. Some simple examples Examples from our webpage Examples from Andrews webpage Today’s Example.
1 JavaScript
JavaScript Scripting language What is Scripting ? A scripting language, script language, or extension language is a programming language.
ECA 225 Applied Interactive Programming1 ECA 225 Applied Online Programming basics.
COP 3813 Intro to Internet Computing Prof. Roy Levow Lecture 1.
ASP. What is ASP? ASP stands for Active Server Pages ASP is a Microsoft Technology ASP is a program that runs inside IIS IIS stands for Internet Information.
JavaScript Introduction.  JavaScript is a scripting language  A scripting language is a lightweight programming language  A JavaScript can be inserted.
Unit 1 Welcome to the Internet: the Tools of the Trade.
ECMM6018 Enterprise Networking for Electronic Commerce Tutorial 7
Scripting Languages Client Side and Server Side. Examples of client side/server side Examples of client-side side include: JavaScript Jquery (uses a JavaScript.
Website design and structure. A Website is a collection of webpages that are linked together. Webpages contain text, graphics, sound and video clips.
JavaScript Defined DOM (Document Object Model) General Syntax Body vs. Head Variables Math & Logic Selection Functions & Events Loops Animation Getting.
CIS 3.5 Lecture 2.3 "Introduction to JavaScript".
Creating Web Documents: JavaScript Ftp / file management: review Introduction to JavaScript Sources Homework: start review for midterm, work on Project.
8 th Semester, Batch 2009 Department Of Computer Science SSUET.
Chapter 5: Intro to Scripting CIS 275—Web Application Development for Business I.
Chapter 4 Java Script - Part1. 2 Outlines Introduction to Java Script Variables, Operators and Functions Conditional statements JavaScript Objects Forms.
1 CSC160 Chapter 1: Introduction to JavaScript Chapter 2: Placing JavaScript in an HTML File.
CGS 3066: Web Programming and Design Spring 2016 Introduction to JavaScript.
JavaScript: A short introduction Joseph Lee Created by Joseph Lee.
Web Programming Java Script-Introduction. What is Javascript? JavaScript is a scripting language using for the Web. JavaScript is a programming language.
COM621: Advanced Interactive Web Development Lecture 6 – JavaScript (cont.)
SlideSet #20: Input Validation and Cross-site Scripting Attacks (XSS) SY306 Web and Databases for Cyber Operations.
Javascript Javascript The JavaScript Programming Language – Scripting Languages Executed by an interpreter contained within.
Tutorial 10 Programming with JavaScript
Chapter 19 PHP Part III Credits: Parts of the slides are based on slides created by textbook authors, P.J. Deitel and H. M. Deitel by Prentice Hall ©
PHP / MySQL Introduction
Introduction to JavaScript
CS105 Introduction to Computer Concepts
Web Programming– UFCFB Lecture 13
Introduction to JavaScript
CS105 Introduction to Computer Concepts JavaScript
Presentation transcript:

JavaScript ICW: Lecture 11 Tom Chothia

Last Lecture URLs Threads, to make a process run in parallel: Make it extend Thread Give it a run method Call start() to set it going.

Exercise Marks for Exercise will go into the SIS later today or tomorrow. Grades: Over 40 Pass Over 60 VERY Good Over 70 Truly Outstanding Exercises are worth 2.5 credits should be hours work.

Marks 40 pass, 60 Merit, 70 Distinction. Distribution of marks:

Marking for Exercise 2 35% How well you handle the HTTP and network communication. 20% Quality of your code. 20% How easy is it to control your browser. 10% How well you display the HTML (use any libraries you like). 15% extra in Part 4.

Today: JavaScript JavaScript is a language for web pages, that will run on the client. It can be added to any HTML file. When the client loads the HTML it will execute the JavaScript. Its not Java, but is kind of OO.

Why Use JavaScript? Shift computation onto the client. Personalise web pages to the reader. Form validation Keeping track of users: cookies. Pop-up, alerts, new windows....

Hello World in JavaScript: Put the JavaScript in a HTML web page. Put JavaScript between the HTML tags... The print command in JavaScript is: document.write( ); HTML between the... will be run if JavaScript is not enabled.

Variables Can declare variables in JavaScript with : var x = 10; var Name = “Tom”; But it’s weakly typed : var x = 11; x=x+3; x=x+”1” x=x+2 x will equal 1412

Control Structors You have all your favourite Java Control Structures: for (var i = 0;i<10;i++){... } if (input=”hello”){...} else {...} while (i<10) {...}

Functions Functions (like methods) can be defined: function helloTime (name) { var now = new Date; if (now.getHours()<12) return ("Good morning "+name); else return ("Good afternoon "+name); }

Functions and Files Put functions in the HTML header. You can link to a function: You can also load functions and script from a file: Loads and runs the JavaScript in the file: file.js

Pop Up Boxes You can open a pop up box with: – alert(“message”); An OK/CANCEL box with: – var r=confirm("Press a button"); Or a prompt box with: – var name=prompt("Enter your name","nobody");

What is This Useful For? You can do a lot with what I have just showed you. But Javascript is most useful for: validating forms, and keeping track of users.

The JavaScript String Object Strings in JavaScript include the following methods: length() indexOf(subString) lastIndexOf(subString) match(pattern)

HTML Forms HTML forms let the user enter data on a website:

HTML Forms onsubmit lets us test the input before accepting it. <form action="thanks.html” onsubmit="return validate_form(this”) method="post">

Cookies Cookies let you store a string on the client. This can be used for – Identify the user, – Storing their name, preferences etc. – Tracking the user: time of last visit, etc. How many cookies are in your browser?

Cookies To create a cookie say: document.cookie = data; Test if a cookie exists with if (document.cookie.length>0) {… Cookie data is often stored as a list field=value, which need to be parsed.

The Navigator Object navigator gives you system information: appName - name of the browser appVersion - version of number cookieEnabled – false if cookies are disabled cpuClass - e.g. "x86" onLine – is there an Internet connection platform -e.g. "Win32" for Windows 95. systemLanguage - language used e.g. "en- us".

Different Browser can act in different ways :-( Internet Explorer will give you the window size using document.body.offsetWidth; Netscape family use: window.innerWidth; You must find the browser type before using these commands.

More JavaScript Uses Make a 10 second counter before forwarding the user to a new site. Opening a new window. Automatically resizing the window based on the users browser.

The Window Object The window object gives you some control over the browser: Close closes browser window Focus brings window to the front Open opens a new URL ResizeTo resizes the window

The History Object The History Objects gives length number of pages in the history previous URL of the last site visited.

Is This to Much? Maybe this is more power and information you want to give to the server? If your worried you can always turn JavaScript off and delete your cookies.

Online Tutorial There is an excellent Java tutorial at: Take some time and go through this to learn more about JavaScript.

Conclusion JavaScript is a language for web pages, that will run on the client. Personalise web pages to the reader. Form validation Keeping track of users: cookies.

Next Time: Java Database connectivity (JDBC) Serious Internet systems usually need a database. JDBC makes interacting with a database easy.