CSE 102 Introduction to Web Design and Programming

Slides:



Advertisements
Similar presentations
Programming Club IIT Kanpur. Work environment Before you begin coding,always set up your work environment to your needs IDE Notepad++ Sublime Text 2.
Advertisements

4.01 Cascading Style Sheets
INTRODUCTION TO WEB DEVELOPMENT AND HTML Lecture 06: Tables - Spring 2011.
1 Events Lect 8. 2 Event-driven Pages one popular feature of the Web is its interactive nature e.g., you click on buttons to make windows appear e.g.,
4.1 JavaScript Introduction
JavaScript Part 1.
CSS Class 7 Add JavaScript to your page Add event handlers Validate a form Open a new window Hide and show elements Swap images Debug JavaScript.
Chapter 1 XHTML: Part I The Web Warrior Guide to Web Design Technologies.
 2001 Prentice Hall, Inc. All rights reserved. 1 Chapter 13 - Dynamic HTML: Object Model and Collections Outline 13.1 Introduction 13.2 Object Referencing.
44238: Dynamic Web-site Development Client Side Programming Ian Perry Room:C48 Extension:7287
CIS 375—Web App Dev II JavaScript I. 2 Introduction to DTD JavaScript is a scripting language developed by ________. A scripting language is a lightweight.
COS 125 DAY 20. Agenda Assignment 8 not corrected yet Assignment 9 posted  Due April 16 New course time line Discussion on Scripts 
HTML Help book. HTML HTML is the programming language used to make web pages for the Internet. HTML stands for Hyper Text Markup Language. HTML is made.
COM621: Advanced Interactive Web Development Lecture 6 – JavaScript (cont.)
What is XHTML? XHTML stands for Extensible Hypertext Markup Language
Introduction to.
Module 1 Introduction to JavaScript
CSE 102 Introduction to Web Design and Programming
CSE 102 Introduction to Web Design and Programming
Event-Driven Programming
CSE 102 Introduction to Web Design and Programming
Section 4.1 Section 4.2 Format HTML tags Identify HTML guidelines
Applied Component I Unit II Introduction of java-script
CSE 102 Introduction to Web Design and Programming
4.01 Cascading Style Sheets
CSS Layouts: Grouping Elements
Web Development & Design Foundations with HTML5
Advanced Web Development IT225
© 2017 Akhilesh Bajaj, All Rights Reserved
Elements of HTML Web Design – Sec 3-2
JavaScript is a programming language designed for Web pages.
W3C Web standards and Recommendations
Donna J. Kain, Clarkson University
JavaScript for Client-Side Computation and Data Validation
Barb Ericson Georgia Institute of Technology May 2006
LAB Work 02 MBA 61062: E-Commerce
Basic XHTML Tables XHTML tables—a frequently used feature that organizes data into rows and columns. Tables are defined with the table element. Table.
Web Development & Design Foundations with HTML5 7th Edition
Chapter 1: Introduction to XHTML (part 1)
XHTML 1 by Carsomyr.
CSE 102 Introduction to Web Design and Programming
COMPUTING FUNDAMENTALS
14 A Brief Look at JavaScript and jQuery.
TOPICS Chrome Dev Tools Process for Building a Static Website
XHTML
HTML A brief introduction HTML.
Chapter 13 - Dynamic HTML: Object Model and Collections
Introduction to DOM.
Introduction There are several good reasons for taking CS142: Web Applications: You will learn a variety of interesting concepts. It may inspire you to.
Using HTML Tables SWBAT: - create tables using HTML
Basic HTML and Embed Codes
CS 142 Lecture Notes: Rails Controllers and Views
The University of Tulsa
JavaScript Programming Labs
Static and Dynamic Web Pages
CS 142 Lecture Notes: Rails Controllers and Views
Introduction to HTML.
Introduction to DHTML, the DOM, JS review
Chapter 7 - JavaScript: Introduction to Scripting
HTML5 and Local Storage.
JavaScript Basics Topics Review Important Methods Writing Functions
JavaScript Basics What is JavaScript?
JavaScript is a scripting language designed for Web pages by Netscape.
Introduction to Programming and JavaScript
Images in HTML PowerPoint How images are used in HTML
XHTML 7-May-19.
4.01 Cascading Style Sheets
XHTML 29-May-19.
Introduction to Cascading Style Sheets (CSS)
Creating Web Documents
Presentation transcript:

CSE 102 Introduction to Web Design and Programming JavaScript

JavaScript A client-side scripting language Common tasks performed by JavaScript in Web pages: asking the browser to display information making the Web page different depending on the browser monitoring user events & specifying reactions generating HTML code for parts of the page modifying a page in response to events checking correctness of input replacing & updating parts of a page changing the style & position of displayed elements dynamically JavaScript is used in www.sunysb.edu, how?

JavaScript background Developed by Netscape, released 1995 Supported by all major browsers The standard client-side scripting language JavaScript programs are not written in Java, these are two different languages JavaScript is object oriented, so there are similarities JavaScript programs are embedded inside Web pages and are executed by browsers

Starting XHTML Document <?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <title>JavaScript Practice Page</title> <link rel="stylesheet" type="text/css" href="./css/javascript.css" /> </head> <body> </body> </html>

Add to your page <div id="date"> <p>Some Client Details:<br /> <script type="text/javascript"> var d = new Date(); var time = d.getHours() + ":" + d.getMinutes() + "."; var agent = navigator.userAgent; document.write("  Date: " + d + "<br />"); document.write("  Time: " + time + "<br />"); document.write("  Agent: " + agent + "</p>"); </script> </div>

javascript.css #date { position : absolute; left : 100px; top : 100px; width : 500px; color:#0000cc; background-color:#dddd00; padding : 10px; }

Add to your page <div id="image_rollover"> <h2>Image Rollover</h2> <p> <img onmouseover= "this.src='http://www.lapropagationduchaos.net/what/homer_vf/culture.gif'" onmouseout= "this.src='http://www.simpsoncrazy.com/homer/31.gif'" src="http://www.simpsoncrazy.com/homer/31.gif" style="border:none; float:left; margin-right:10px" width="100" height="100"> Rollover Homer to get him to taunt you. </p> </div>

Add to your Page <div id="history"> <p> <a href="javascript:history.back()">Back</a>        <a href="javascript:history.forward()">Forward</a>        <a href="javascript:history.go(-2)">Back 2 Pages</a> </p> </div>

Add to your Page <div id="dialogs"> <p> <a href="javascript:alert('This script is for giving alerts, like when your credit card number is invalid.');">Alert</a><br /> <a href="javascript:var email = prompt('This script will ask for input. Please enter you email address:'); confirm('Email is: ' + email);history.refresh()">Prompt</a><br /> <a href="javascript:window.open('http://www.lapropagationduchaos.net/what/homer_vf/culture.gif', 'Homer', 'scrollbars=no, toolbar=no, height=200, width=200, screenX=300, screenY=300'); history.refresh()"> Popup Homer</a> </p> </div>

JavaScript Files We can keep JavaScript files separate from .html files .js files are JavaScript files Then these programs may be used by many Web pages

Create a New Web Page <?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <title>Inch Centimeter Converter</title>   <script type="text/javascript" src="convert.js" xml:space="preserve" ></script>   </head> <body onload="init()">   <h2>Conversion Calculation via Javascript</h2>   <p>Enter either value then click the convert button:</p> <table cellspacing="6"> <tr valign="top"> <td rowspan="1" colspan="1">   <input id="inch" name="inch" size="20" onfocus="reset()" type="text" />   <br />   Inches   </td>   <input type="button" value="Convert" onclick="convert()" />   <input id="cm" name="cm" size="20" onfocus="reset()" type="text" />   Centimeters   </tr>   </table>   </body>   </html>

convert.js var inf, cmf; function init() { inf = document.getElementById('inch'); cmf = document.getElementById('cm'); } function convert() { var i = inf.value.replace(/ /,""); if ( i ) { cmf.value = i * 2.54; return; var c = cmf.value.replace(/ /,""); if ( c ) { inf.value = c / 2.54; function reset() { inf.value = ""; cmf.value = "";

Make a new Web page <?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head>   <title>Slide Demo with Arrow Keys</title>   <script type="text/javascript" src="slidekey.js" xml:space="preserve"> </script>   </head> <body onload="changeSlide()" style="background-color: #666" onkeydown="keyGo(event)"> <p style="text-align: center; color: white; font-weight: bold">   <img src="" id="myimg" name="myimg" alt="slide" />   <br />   Use left and right arrow keys to view the slides.   </p>   </body>   </html>

slidekey.js var index = 0; // current slide index var pic = [ "homer1.jpg", "homer2.jpg", "homer3.jpg", "homer4.jpg", "homer5.jpg" ]; var slide = new Array(); var index = 0; // current slide index function loadImage(url) { if (document.images) { rslt = new Image(); rslt.src = url; return rslt; } if ( document.images ) { for (var n=0; n < pic.length; n++) { slide[n] = loadImage(pic[n]); function prevSlide() { if(--index < 0) { index = pic.length-1; changeSlide(); function nextSlide() { if( ++index >= pic.length) { index = 0 function changeSlide() { document.getElementById('myimg').src = slide[index].src; function keyGo(e) { if ( e.keyCode == 39 ) nextSlide(); else if ( e.keyCode == 37 ) prevSlide(); slidekey.js