The Magic of Dynamic Web Pages Doncho Minkov Telerik Software Academy academy.telerik.com Technical Trainer

Slides:



Advertisements
Similar presentations
Chapter 7 JavaScript: Introduction to Scripting. Outline Simple Programs Objects and Variables Obtaining User Input with prompt Dialogs – –Dynamic Welcome.
Advertisements

JavaScript FaaDoOEngineers.com FaaDoOEngineers.com.
The Web Warrior Guide to Web Design Technologies
Web Page Behavior IS 373—Web Standards Todd Will.
Dynamic Web Pages Bert Wachsmuth. Review  Internet, IP addresses, ports, client-server, http, smtp  HTML, XHTML, XML  Style Sheets, external, internal,
2012 •••••••••••••••••••••••••••••••••• Summer WorkShop Mostafa Badr
Inline, Internal, and External FIle
Introduction to JavaScript. Aim To enable you to write you first JavaScript.
DHTML - Introduction Introduction to DHTML, the DOM, JS review.
DHTML. What is DHTML?  DHTML is the combination of several built-in browser features in fourth generation browsers that enable a web page to be more.
4.1 JavaScript Introduction
JavaScript and The Document Object Model MMIS 656 Web Design Technologies Acknowledgements: 1.Notes from David Shrader, NSU GSCIS 2.Some material adapted.
Copyright © Texas Education Agency, All rights reserved. 1 Web Technologies Website Development with Dreamweaver.
Introduction to JavaScript Dr. John P. Abraham University of Texas – Pan American.
W. W. Milner JavaScript. W. W. Milner Chapter 1 - Intro Why use JavaScript? Interactivity LiveScript JavaScript Jscript ECMAScript JavaScript is not Java!
Scripting Languages.
UNIT 3 DYNAMIC WEBSITES WITH CSS AND JAVASCRIPT. OBJECTIVES  CO4 Apply style to a website using CSS.  CO5 Describe the use of scripting when creating.
Web Technologies Website Development Trade & Industrial Education
JavaScript Defined DOM (Document Object Model) General Syntax Body vs. Head Variables Math & Logic Selection Functions & Events Loops Animation Getting.
What is a dynamic web site and how to create it? Svetlin Nakov Telerik School Academy schoolacademy.telerik.com Technical Trainer
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.
Past, Present and Future Nikolay Kostov Telerik Software Academy academy.telerik.com Team Lead, Senior Developer and Trainer
WEEK 3 AND 4 USING CLIENT-SIDE SCRIPTS TO ENHANCE WEB APPLICATIONS.
Unobtrusive JavaScript
CNIT 133 Interactive Web Pags – JavaScript and AJAX JavaScript Environment.
Lesson 19. JavaScript errors Since JavaScript is an interpreted language, syntax errors will usually cause the script to fail. Both browsers will provide.
UFCEWT-20-3 Advanced Topics in Web Development Lecture 4 : JavaScript, Browsers & the HTML DOM-API.
DHTML: Dynamic HTML Internet Technology1. What is DHTML? A collection of enhancements to HTML ► To create dynamic and interactive websites Combination.
Website Development with Dreamweaver
JavaScript Development Introduction First Steps in JavaScript SoftUni Team Technical Trainers Software University
SEG3210 DHTML Tutorial. DHTML DHTML is a combination of technologies used to create dynamic and interactive Web sites. –HTML - For creating text and image.
CITS1231 Web Technologies JavaScript and Document Object Model.
Client Scripting1 Internet Systems Design. Client Scripting2 n “A scripting language is a programming language that is used to manipulate, customize,
Javascript. Outline Introduction Fundamental of JavaScript Javascript events management DOM and Dynamic HTML (DHTML)
JavaScript. Overview Introduction: JavaScript basics Expressions and types Expressions and types Arrays Arrays Objects and Associative Arrays Objects.
An Introduction to JavaScript Summarized from Chapter 6 of “Web Programming: Building Internet Applications”, 3 rd Edition.
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,
JavaScript - A Web Script Language Fred Durao
JavaScript Development Introduction First Steps in JavaScript Svetlin Nakov Technical Trainer Software University
Unleash the Power of jQuery Doncho Minkov Telerik Software Academy academy.telerik.com Senior Technical Trainer
DOM Document Object Model (DOM) SoftUni Team Technical Trainers Software University
Client-side processing in JavaScript.... JavaScript history Motivations –lack of “dynamic content” on web pages animations etc user-customised displays.
1 JavaScript
JavaScript Scripting language What is Scripting ? A scripting language, script language, or extension language is a programming language.
Web Development 101 Presented by John Valance
Cs332a_chapt10.ppt CS332A Advanced HTML Programming DHTML Dynamic Hypertext Markup Language A term describing a series of technologies Not a stand-a-lone.
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,
Unleash the Power of jQuery Learning & Development Team Telerik Software Academy.
JavaScript Introduction.  JavaScript is a scripting language  A scripting language is a lightweight programming language  A JavaScript can be inserted.
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.
CIS 3.5 Lecture 2.3 "Introduction to JavaScript".
Copyright © Terry Felke-Morris WEB DEVELOPMENT & DESIGN FOUNDATIONS WITH HTML5 7 TH EDITION Chapter 14 Key Concepts 1 Copyright © Terry Felke-Morris.
Introduction to JavaScript
JavaScript and Ajax (JavaScript Environment) Week 6 Web site:
The Magic of Dynamic Web Pages Telerik Software Academy JavaScript Fundamentals.
Chapter 13: DHTML: Object Model and Collections CIS 275—Web Application Development for Business I.
COM621: Advanced Interactive Web Development Lecture 6 – JavaScript (cont.)
Copyright © Terry Felke-Morris Web Development & Design Foundations with HTML5 8 th Edition CHAPTER 14 KEY CONCEPTS 1 Copyright.
Introduction to.
CIIT-Human Computer Interaction-CSC456-Fall-2015-Mr
Web Development & Design Foundations with HTML5 7th Edition
Introduction to JavaScript Development
DHTML Javascript Internet Technology.
DHTML Javascript Internet Technology.
Introduction to DHTML, the DOM, JS review
Presentation transcript:

The Magic of Dynamic Web Pages Doncho Minkov Telerik Software Academy academy.telerik.com Technical Trainer

 Dynamic HTML  How to Create DHTML?  XHTML, CSS, JavaScript, DOM  Intro to JavaScript  History  JavaScript in Web Pages  JavaScript Syntax  Pop-up boxes  Debugging in JavaScript 2

Dynamic Behavior at the Client Side

 Dynamic HTML (DHTML)  Makes possible a Web page to react and change in response to the user’s actions  DHTML consists of HTML + CSS + JavaScript 4DHTML XHTMLCSSJavaScriptDOM

 HTML defines Web sites content through semantic tags (headings, paragraphs, lists, …)  CSS defines 'rules' or 'styles' for presenting every aspect of an HTML document  Font (family, size, color, weight, etc.)  Background (color, image, position, repeat)  Position and layout (of any object on the page)  JavaScript defines dynamic behavior  Programming logic for interaction with the user, to handle events, etc. 5

Dynamic Behavior in a Web Page

 JavaScript is a front-end scripting language developed by Netscape for dynamic content  Lightweight, but with limited capabilities  Can be used as object-oriented language  Embedded in your HTML page  Interpreted by the Web browser  Client-side, mobile and desktop technology  Simple and flexible  Powerful to manipulate the DOM 7

 JavaScript allows interactivity such as:  Implementing form validation  React to user actions, e.g. handle keys  Changing an image on moving mouse over it  Sections of a page appearing and disappearing  Content loading and changing dynamically  Performing complex calculations  Custom HTML controls, e.g. scrollable table  Implementing AJAX functionality 8

 Can handle events  Can read and write HTML elements and modify the DOM tree  Can validate form data  Can access / modify browser cookies  Can detect the user’s browser and OS  Can be used as object-oriented language  Can handle exceptions  Can perform asynchronous server calls (AJAX) 9

10 <html><body> alert('Hello JavaScript!'); alert('Hello JavaScript!'); </body></html>

Live Demo 11

 The JavaScript code can be placed in:  tag in the head  tag in the body - not recommended  External files, linked via tag the head  Files usually have.js extension  Highly recommended  The.js files get cached by the browser 12 </script>

 JavaScript code is executed during the page loading or when the browser fires an event  All statements are executed at page loading  Some statements just define functions that can be called later  Function calls or code can be attached as "event handlers" via tag attributes  Executed when the event is fired by the browser 13

<html><head> function test (message) { function test (message) { alert(message); alert(message); }</script></head><body> <img src="logo.gif" <img src="logo.gif" onclick="test('clicked!')" /> onclick="test('clicked!')" /></body></html> 14

Live Demo 15

 Using external script files:  External JavaScript file: 16 <html><head> </head><body> <button onclick="sample()" value="Call JavaScript <button onclick="sample()" value="Call JavaScript function from sample.js" /> function from sample.js" /></body></html> function sample() { alert('Hello from sample.js!') alert('Hello from sample.js!')} external-JavaScript.html sample.js The tag is always empty.

Live Demo 17

 The JavaScript syntax is similar to C#  Operators ( +, *, =, !=, &&, ++, …)  Variables (typeless)  Conditional statements ( if, else )  Loops ( for, while )  Arrays ( my_array[] ) and associative arrays ( my_array['abc'] )  Functions (can return value)  Function variables (like the C# delegates) 19

 Alert box with text and [OK] button  Just a message shown in a dialog box:  Confirmation box  Contains text, [OK] button and [Cancel] button:  Prompt box  Contains text, input field with default value: 20 alert("Some text here"); confirm("Are you sure?"); prompt ("enter amount", 10);

Live Demo 21

 The browser provides some read-only data via:  window  The top node of the DOM tree  Represents the browser's window  document  holds information the current loaded document  screen  Holds the user’s display properties  browser  Holds information about the browser 23

24 window navigatorscreendocumenthistorylocation form buttonform form

 window.open() 25 var newWindow = window.open("", "sampleWindow", "width=300, height=100, menubar=yes, "width=300, height=100, menubar=yes, status=yes, resizable=yes"); status=yes, resizable=yes");newWindow.document.write( " " Sample Title Sample Title Sample Sample Text "); Text "); newWindow.status = "Hello folks"; "Hello folks"; window-open.html

26 alert(window.navigator.userAgent); The navigator in the browser window The userAgent (browser ID) The browser window

 The screen object contains information about the display 27 window.moveTo(0, 0); x = screen.availWidth; y = screen.availHeight; window.resizeTo(x, y);

 document object  Provides some built-in arrays of specific objects on the currently loaded Web page  document.location  Used to access the currently open URL or redirect the browser 28 document.links[0].href = "yahoo.com"; document.write( "This is some bold text "); "This is some bold text "); document.location = "

Live Demo 29

 The Math object provides some mathematical functions 31 for (i=1; i<=20; i++) { var x = Math.random(); var x = Math.random(); x = 10*x + 1; x = 10*x + 1; x = Math.floor(x); x = Math.floor(x); document.write( document.write( "Random number (" + "Random number (" + i + ") in range " + i + ") in range " + " > " + x + " > " + x + " "); " ");} math.html

 The Date object provides date / calendar functions 32 var now = new Date(); var result = "It is now " + now; document.getElementById("timeField").innerText = result;.innerText = result;... dates.html

 Make something happen (once) after a fixed delay 33 var timer = setTimeout('bang()', 5000); clearTimeout(timer); 5 seconds after this statement executes, this function is called Cancels the timer

 Make something happen repeatedly at fixed intervals 34 var timer = setInterval('clock()', 1000); clearInterval(timer); This function is called continuously per 1 second. Stop the timer.

35 function timerFunc() { function timerFunc() { var now = new Date(); var now = new Date(); var hour = now.getHours(); var hour = now.getHours(); var min = now.getMinutes(); var min = now.getMinutes(); var sec = now.getSeconds(); var sec = now.getSeconds(); document.getElementById("clock").value = document.getElementById("clock").value = "" + hour + ":" + min + ":" + sec; "" + hour + ":" + min + ":" + sec; } setInterval('timerFunc()', 1000); setInterval('timerFunc()', 1000);</script> timer-demo.html

Live Demo 36

 Modern browsers have JavaScript console where errors in scripts are reported  Errors may differ across browsers  Several tools to debug JavaScript  Microsoft Script Editor  Add-on for Internet Explorer  Supports breakpoints, watches  JavaScript statement debugger ; opens the script editor 38

 Firebug – Firefox add-on for debugging JavaScript, CSS, HTML  Supports breakpoints, watches, JavaScript console editor  Very useful for CSS and HTML too  You can edit all the document real-time: CSS, HTML, etc  Shows how CSS rules apply to element  Shows Ajax requests and responses  Firebug is written mostly in JavaScript 39

40

 The console object exists only if there is a debugging tool that supports it  Used to write log messages at runtime  Methods of the console object:  debug(message)  info(message)  log(message)  warn(message)  error(message) 41

Questions?

 "Web Design with HTML 5, CSS 3 and JavaScript" Telerik Academy  html5course.telerik.com html5course.telerik.com  Telerik Software Academy  academy.telerik.com academy.telerik.com  Telerik Facebook  facebook.com/TelerikAcademy facebook.com/TelerikAcademy  Telerik Software Academy Forums  forums.academy.telerik.com forums.academy.telerik.com