a Why JavaScript? jonkv interactivity on the web CGI JavaScript Java Applets Netscape LiveScript JavaScript 1: Example

Size: px
Start display at page:

Download "a Why JavaScript? jonkv interactivity on the web CGI JavaScript Java Applets Netscape LiveScript JavaScript 1: Example"

Transcription

1 Why JavaScript? 2 JavaScript JavaScript the language Web page manipulation with JavaScript and the DOM : Wanted interactivity on the web Server side interactivity: CGI Common Gateway Interface Batch oriented (fill in a form, get interactive results) "Heavy weight" client side interactivity: Java Applets Self contained part of a web page Interacts with the user + possibly a server Does not interact with the document itself (Interactive versions of Macromedia Flash not available until 1998) "Light weight" client side interactivity: Netscape LiveScript Script language for the web (introduced late 1995) Renamed to JavaScript (marketing!) Standardized version: ECMAscript (ECMA 262, ISO 16262) Also used in Flash, Firefox/Thunderbird UI, PDF files, MacOS Dashboard Widgets, PhotoShop, JavaScript 1: Example 3 JavaScript 2: Script files 4 A simple JavaScript example: In HTML, scripts are CDATA not parsed by browsers, validators <!DOCTYPE HTML PUBLIC > <HTML> <head> <title>hello, World!</title> <script type="text/javascript"> alert("hello, World!"); // Show an alert to the user </script> </head><body> </body></html> In XHTML, your inline code is by default PCDATA (parsed) if (a < b) the < will be interpreted as the start of a tag <script type="text/javascript"> /* <![CDATA[ */ your code /* ]]> */ </script> Better solution: Separate script file Test.html: <!DOCTYPE HTML PUBLIC > <HTML> <head> <title>hello, World!</title> </head> <body> <script type="text/javascript" src="example.js"></script> </body> </HTML> example.js: // Show an alert to the user alert("hello, World!");

2 JavaScript 3: Types and type checking 5 JavaScript 4: Control 6 Like many script languages: No static type checking Variables are always declared with "var", not with a type var myvar = "Testing"; myvar = 10; myvar = true; Example: Some calculations var secs_per_min = 60; var mins_per_hour = 60; var hours_per_day = 24; var secs_per_day = secs_per_min * mins_per_hour * hours_per_day; Special values: null (behaves like 0 in numeric context, false in boolean context) undefined (behaves like false in boolean context) Control structures are similar to Java if (condition) { else { switch / case for (var i= 0; i < 10; i++) { while (condition) { do { while (condition) break / continue try { throw new ; catch (e) { finally { try { throw "Something"; catch (e) { finally { // Comment /* Long comment */ JavaScript 5: Operators 7 JavaScript 6: Functions 8 Operators are similar to Java, C, C++ ==!= // equals (tries to convert types before comparison) ===!== // (strict equals no type conversion) + * / < > << >> >>>// left shift, right shift, unsigned right shift += = *= /= ++, &&, Functions: Declared using the "function" keyword Late type checking: Don't declare parameter types function get_secs(days) { var secs_per_min = 60; var mins_per_hour = 60; var hours_per_day = 24; var secs_per_day = secs_per_min * mins_per_hour * hours_per_day; return days * secs_per_day; var secs_per_week = get_secs(7); Checking whether functions exist: if (get_secs) { Important! Used to check the level of JavaScript support. Important! Used to check the level of DOM support.

3 JavaScript 7: Object-oriented 9 JavaScript 8: Constructors 10 Object oriented but not class based Can use constructors if you want to Individual objects can have their own methods or fields Names the type ("Person") var me = new Object(); me.name = "Jonas Kvarnström"; // Creates a "name" field me.phone = null; me.getname = function() { return this.name; var you = new Object(); you.name = "Jane Doe"; you.address = "somewhere"; Literal notation: function Person(name, phone) { this.name = name; this.phone = phone; this.getname = function() { return this.name; var me = new Person("Jonas Kvarnström", "2305"); Can still add methods / fields incrementally var me = { name: "Jonas Kvarnström", phone: null, getname: function() { return this.name; ; Only weak syntax checking possible me.address = "Somewhere"; me.setaddress = function(addr) { this.address = addr; alert(me.phone); // OK alert(you.phone); // No such property (runtime error) JavaScript 9: Adding new methods 11 JavaScript 10: Adding to prototype 12 Inheritance based on prototypes Each object inherits properties from a prototype object function Employee(name, phone, department) { this.name = name; this.phone = phone; this.department = department; var me = new Employee("Jonas", "2305", "IDA"); me.prototype = new Person(); // Inheritance on a per object level! me.getphone(); // works inherited function from prototype Set the prototype of a constructor method Default prototype for objects constructed using Employee function Employee.prototype = new Person(); // "extends Person" Can add properties to the prototype at any time! Incremental extension person.prototype.getphone = function() { return phone; Now all "person" objects have this method Works for built in classes too! if (!String.prototype.trim) { // If trim does not exist String.prototype.trim = function() { return this.replace(/^\s+/,"").replace(/\s+$/,"");

4 JavaScript 11: Arrays 13 JavaScript 12: Associative arrays 14 Arrays: Kind of like Java arrays Allocated with new operator, or [] syntax var names1 = new Array("Roger", "Moore"); var names2 = [ "Roger", "Moore" ]; var empty = new Array(10); Indexed using [] syntax names[0] == "Roger" empty[0] == undefined Have a.length property Example: var reply = prompt("what's your name?", ""); var names = reply.split(" "); for (var pos = 0; pos < names.length; pos++) { alert("one of your names is " + names[pos]); Useful array methods concat joins two arrays join joins array elements into string push(x), pop() slice() returns a subsection of the array splice() adds/removes elements sort() Arrays can be associative Can replace Map / HashMap in Java var phonenumbers = new Array(); phonenumbers["jonas"] = "070 xxxxxxx"; phonenumbers[ Martin"] = "070 xxxxxxx"; Can iterate over all keys for (var name in phonenumbers) { // Jonas, Martin, dosomethingwith(phonenumbers[name]); Properties and arrays: Different interfaces, same data structure var me = new Person("Jonas Kvarnström", null); me["name"] = "Jonas Kvarnström"; for (var prop in me) { /* iterate over "name", "phone", "getname" */ JavaScript 13: Strings 15 JavaScript 14: Dates 16 String Single or double quotes var myvar = 'asdf', othervar = "qwerty"; Fields: length General Methods charat, charcodeat, indexof, lastindexof fromcharcode // from sequence of Unicode values "abc def ghi".split(" ") == array containing "abc", "def", "ghi" substring, substr, slice, concat match, replace, search // regular expressions tolowercase, touppercase HTML related Methods anchor, link // HTML named anchor / hyperlink big, blink, bold, fixed, italics, small, strike, sub, sup Date Constructors var date = new Date(); // today var date = new Date("December 31, :34:56"); var date = new Date(2010, 12, 31); Methods getyear(), getmonth(), getdate, getday() // and setters gethour(), getminute(), getsecond() // and setters getfullyear() // four digit year

5 JavaScript 15: History and Window 17 Browser specific JavaScript objects: history the page history history.back(), history.forward() history.go(delta) // 1 = back, 2 = 2 steps back,... history.go(' // nearest URL containing ' window.location the current location URL window.location = " // New history entry window.location.reload(); window.location.replace(" // No new entry DOM: The Document Object Model Accessing the Structure of a Document Manipulating HTML 19 DOM 1: Document Object Model 20 Many web apps actively manipulate HTML / XML Populate dropdown boxes depending on previous choices Select country "Sweden" add Swedish cities to the city dropdown Hide and show elements of a web page Click "advanced" to show additional fields in a form Check the validity of form input fields Show errors without requiring a round trip to the server W3C DOM: Document Object Model A document is a tree of nodes with attributes Well defined standard Specified using IDL, the Interface Definition Language Implemented in many different languages, including JavaScript <THead> <Table> <TBody> <TR> <TR> <TR> <TR> <TH> <TH> <TD> <TD> Item Price Foo $100.00

6 DOM 2: Navigating through Documents 21 DOM 3: Element and Text Nodes 22 The document is also a node In JavaScript: Accessed through the document variable Has methods for finding other nodes Give an element a name: <span id="foo">change this text</span> var foonode = document.getelementbyid( foo ); var allspans = document.getelementsbytagname( span ); All nodes have methods for treetraversal readonly attribute Node parentnode; readonly attribute NodeList childnodes; boolean haschildnodes(); and for tree manipulation: Node Node Node Node insertbefore(in Node newchild, in Node refch); replacechild(in Node newchild, in Node oldch); removechild(in Node oldchild); appendchild(in Node newchild); Element and Text node <p>this is a paragraph</p> <p> This is a paragraph interface CharacterData : Node { attribute DOMString data; readonly attribute unsigned long length; void replacedata(in unsigned long offset, in unsigned long count, in DOMString arg) void insertdata(in unsigned long offset, in DOMString arg) void deletedata(in unsigned long offset, in unsigned long count) void appenddata(in DOMString arg) ; interface Text : CharacterData { Text splittext(in unsigned long offset); ; Element node Text node DOM 4: Attribute Nodes 23 DOM 5: Composite Example 24 Each node has an attribute list <P STYLE= >This is a <span>paragraph</span> </P> <img src="foo.png" height="100" width="300"> <img> SRC foo.png height 100 Attr nodes width 300 This is a <p> <span> STYLE DOMString getattribute(in DOMString name); void setattribute(in DOMString name, in DOMString value); void removeattribute(in DOMString name); Attr getattributenode(in DOMString name); Attr setattributenode(in Attr newattr); Attr removeattributenode(in Attr oldattr); interface Attr : Node { readonly attribute DOMString name; readonly attribute boolean specified; attribute DOMString value; ; paragraph

7 DOM/JS 1: DOM in JavaScript 26 Using the DOM in JavaScript JavaScript has a standard DOM implementation Interfaces represented as JavaScript objects / prototypes Several standard objectsalwaysavailable document the current page (HTMLDocument) window the current window location the current URL being displayed (window.location) navigator the browser (version, platform, ) screen screen properties Now: Using DOM interfaces in JavaScript 27 Dynamic document generation 1 28 Example 1 Dynamic Document Generation Dynamic document generation using writeln() Simple but not very structured often discouraged var secs_per_min = 60; var mins_per_hour = 60; var hours_per_day = 24; var secs_per_day = secs_per_min * mins_per_hour * hours_per_day; document.writeln("<p>there are "); document.writeln(secs_per_day); document.writeln(" seconds per day"); Example: ex1.html

8 Dynamic document generation Dynamic document generation, structured Simple example: Naming an element, modifying it <body> <h2>hello, World!</h2> <p>i can <span id= changespan">change this text</span>! <p><a href= javascript_required.html onclick= changetext('changespan', 'modify stuff')">do it!</a> </body> Example 2 Document Manipulation: Dynamically Adding Rows to Search Forms function changetext(id, text) { var element = document.getelementbyid(id); var textnode = element.firstchild; <span> change what I wrote Search for messages matching: term1 term1 textnode.data = text; Example: ex2.html term1 New row Dynamically Adding Rows 1 31 Dynamically Adding Rows 2 32 First shot: <!DOCTYPE HTML PUBLIC > <html> <head><title>dynamic Forms</title></head> <body><h3>dynamic Forms</h3> <form> <table> Next one should be named input1 <tbody id= searchtable"> <tr><td><input type="text" name= input0"></td></tr> </tbody> </table> <input type="button" value="add row onclick="addrow( searchtable');"> </form> </body> </html> Instead of a link: Button with HTML event handling (onclick) Create a new <tr> row in addrow()... No constructors exist in IDL instead, factory methods HTMLTableElementprovides insertrow() HTMLTableRowElement provides insertcell() Document provides generic factory methods Element createelement(in DOMString tagname) raises(domexception); Text createtextnode(in DOMString data); Attr createattribute(in DOMString name) raises(domexception); function addrow(someid) { // Param is ID from <tbody id="mybody"> var tbody = document.getelementbyid(someid); var newrow = tbody.insertrow(-1); var newcell = newrow.insertcell(-1); var newinput = document.createelement("input"); newinput.type = "text"; // HTML attributes available as fields! newinput.name = input" + tbody.rows.length; // input1, input2, newcell.appendchild(newinput); Example: ex3b.html

9 33 Collapsing and Expanding 1 34 Example 3 Expanding and Collapsing Elements Expand / collapse elements example: sidebar menus Click header => toggle visibility of link box <tr><td id="general" onclick="toggleblock('generalbox'); >General</td></tr> <tr><td class="linkbox" id="generalbox"> <a class="nav" href="prerequisites.html">prerequisites</a><br> <a class="nav" href="staff.html">staff</a><br> </td> </tr> JavaScript code to toggle CSS display property for one block: function toggleblock(id) { var style = document.getelementbyid(id).style; if (style.display == 'none') { style.display = 'block ; else { style.display = 'none'; Example: Old Course Pages 35 Hover Menus 1 36 Example 4 CSS + JavaScript Hover Menus Goal: Top level navigation menu with dropdowns Determine what HTML markup to use Determine what can be done with pure HTML+CSS Might need some scripts too! (adapted from "Suckerfish Dropdowns" at

10 Hover Menus 2 37 Hover Menus 3 38 Markup: The structure of a menu is a nested list! <ul class="menu"> <li>sunfishes <ul> <li><a href="">blackbanded sunfish</a></li> <li><a href="">shadow bass</a></li> <li><a href="">ozark bass</a></li> <li><a href="">white crappie</a></li> </ul> </li> <li>grunts <ul>... </ul> </li> </ul> <p>here is some text after the menu</p> Suitable structure, but the default display is bad! Don't show as a bullet list Remove list related margins ul.menu, // any UL of class menu ul.menu ul // any UL inside an UL of class menu { padding: 0; // No padding or margins for these elements margin: 0; list style: none; // Don't show as a bullet list! Hover Menus 4 39 Hover Menus 5 40 We wanted a horizontal menu! Let menu items float At the current y position As far left as possible Give them a constant width (for better appearance) ul.menu li { // any LI inside an UL of class menu float: left; position: relative; width: 10em; Oops! What comes after "float: left" continues at the same line! This is intended behaviour lets you float an image to the left To "continue after floating elements", use clear clear: left after all elements floating left clear: right after all elements floating right clear: both after all floating elements... </li> </ul> <div class="aftermenu"></div> <p>here is some text after the menu</p> div.aftermenu { clear: both;

11 Hover Menus 6 41 Hover Menus 7 42 Submenus should initially be hidden! ul.menu li ul { display: none; When we hover over their parents, they should be seen ul.menu li:hover ul { display: block; This selector is more specific than ul.menu li ul, and takes precedence Drop down menus should not move other text! Achieved through CSS position attribute position: static default position: relative at an offset from normal position position: absolute willnot affect layout of other components position: fixed relative to window (does not move when scrolling) ul.menu li ul { display: none; position: absolute; Also give a background color (otherwise transparent) ul.menu li ul { display: none; position: absolute; background: rgb(230, 230, 230); visuren.html#positioning-scheme Hover Menus 8 43 Hover Menus 9 44 Bad layout in Internet Explorer 6 (20% market share)! Must specify non default top/leftcoordinates ul.menu li ul { display: none; position: absolute; top: 1em; left: 0; but this looks bad in Opera! Use the ">" selector ("immediately within") Opera and others understand this rule and apply it IE 6 does not understand the rule ignores it ul.menu li > ul { top: auto; left: auto; Still does not work in Internet Explorer 6! IE 6 only supports :hover for links (<a ></a>) We used it for <li> attributes Workaround: JavaScript for IE 6 Add an alternative to :hover the over class ul.menu li:hover ul, ul.menu li.over ul { display: block; Must add "over" class dynamically when hovering Must remove "over" class dynamically when not hovering

12 Hover Menus Hover Menus Dynamic addition/removal of classes Step 2: Function adding event handlers Call suitable JavaScript functions from HTML event handlers mouseover event add "over" class menu shown mouseout event remove "over" class menu hidden Could specify mouseover / mouseout for each <li> Repetitive Intrusive Ugly code Mixes semantic markup with programming Better: Let JavaScript analyze the DOM + add event handlers! Step 1: Identifying the navigation list <ul class="menu" id="nav"> startlist() { // Only if IE 5+ (supports doc.all and doc.getelbyid) if (document.all && document.getelementbyid) { navroot = document.getelementbyid("nav"); for (i=0; i<navroot.childnodes.length; i++) { node = navroot.childnodes[i]; if (node.nodename=="li") { node.onmouseover = function() { this.classname+=" over"; node.onmouseout = function() { this.classname=this.classname.replace(" over", ""); Hover Menus Hover Menus Step 3: When to call this function? Not "inline" The script might be executed before the navigation menu is loaded! Use an onload event handler window.onload=startlist; Executed immediately after the page is fully loaded Still an ugly menu usecss to improve Font settings ul.menu { font: 11pt "Myriad Web"; Background + subtle border for line items ul.menu li { background: rgb(240,240,230); border bottom: 1px solid rgb(230,230,220); padding: 0.4ex; When hovering, use a brighter background ul.menu li:hover { background: rgb(250,250,240); Adjust submenu for padding ul.menu li ul { margin top: 0.4ex;

13 Hover Menus Submenu items have another color ul.menu li ul li { background: rgb(230,230,220); border bottom: 1px solid rgb(220,220,210); Hovering over submenu items Example 5 Form Input Validation (JavaScript and server side!) ul.menu li ul li:hover { background: rgb(240,240,230); Links are black, not underlined ul.menu li a { text decoration: none; color: black; Form Validation 1 51 Form Validation 2 52 Form validation tests constraints on valid input Users must provide an e mail address Enter new password twice to detect typing mistakes fields must match Messages must have a subject No letters in numeric fields Server side validation takes time! Not much but a complete roundtrip is required Post form data to server Server validates data If something is wrong: Show the same form again, with errors marked Client side validation is faster / more interactive! Use JavaScript Immediate validation of input How? Use onchange attribute to call a validation method What to do if there is an error? Don't show a dialog window! Intrusive, annoying Preferred: Show a text label indicating there is an error Age: 1a Age: 200 Error: Must be numeric Error: Number too large Can also use this technique to show warnings Age: 105 Warning: Please check

14 Form Validation 3 53 Form Validation 4 54 Example: Immediate input validation Need label + input field + warning field <tr> <td><label for="age">your age (years):</label></td> <td><input id="age" name="age"type="text" onchange="validateage(this, 'inf_age', false);" maxlength="5" size="35"></input></td> <td id="inf_age"> </td> </tr> Need a validation method validateage() function validateage(valfield, // actual element to be validated infofield, // id of element for info/error msg required) { // true if value required // (omitted checking that the value is present) var age = trim(valfield.value); // Assume trim function available var agere = /^[0-9]{1,3$/ // start digits, 1 to 3 of them end if (!agere.test(age)) { msg(infofield, "error", "ERROR: not a valid age"); return false; if (age>=200) { msg(infofield, "error", "ERROR: not a valid age"); return false; if (age>110) msg(infofield, "warn", "Older than 110: check"); else { if (age<7) msg(infofield, "warn", "Are you really that young?"); else msg(infofield, "warn", ""); return true; Form Validation 5 55 Form Validation 6: CSS 56 function msg(fld, // id of element to display message in msgtype, // class to give element ("warn" or "error") message) // string to display { var elem = document.getelementbyid(fld); var emptystring = /^\s*$/ ; if (emptystring.test(message)) { // setting an empty string can give problems if later set to a // non-empty string, so ensure a space (nbsp) is present. var nbsp = 160; elem.firstchild.nodevalue = String.fromCharCode(nbsp); else { elem.firstchild.nodevalue = message; elem.classname = msgtype; // set CSS class to adjust appearance CSS code for message types Info: Black text.info { color: black; font weight: normal; Warning: Dark red.warn { color: rgb(120,0,0); font weight: normal; Error: Red, bold.error { color: red; font weight: bold

15 Form Validation 7: Not only inline 57 Form Validation 8: Validation Alert 58 Inline warnings are perhaps too unobtrusive Easy to miss May also want to check errors at form submission time Warnings should be ignored Errors should lead to an alert popup, stop form submission How to stop form submission? Use onsubmit handler if it returns false, submission is cancelled <FORM id="mf" onsubmit="return validateonsubmit()" action=" "> </FORM> The validation function calls all individual validators Validators return false for error, true for warning/ok! function validateage(valfield, infofield, required) { if (error) { set error message; return false; if (warn) { set warn message; return true; function validateonsubmit() { var errs=0; var myform = document.getelementbyid(" "); if (!validatephone (myform.phone, 'inf_phone', true)) errs += 1; if (!validateage (myform.age, 'inf_age', false)) errs += 1; if (!validate (myform. , 'inf_ ', true)) errs += 1; if (!validatepresent(myform.from, 'inf_from')) errs += 1; if (errs>1) alert('there are fields which need correction'); if (errs==1) alert('there is a field which needs correction'); return (errs==0); ; Form Validation 9: Potential Mistakes Potential mistakes in client side form validation: Only client side validation Clients can manipulate code / turn off JavaScript Must validate on the server too! Validation that fails without JavaScript Clients can turn off JavaScript / run browsers without JavaScript Must be able to fall back to plain server side checking Use a plain submit button not a JS event handler that posts form data Too strict validation Requiring a middle initial Requiring a state but in Sweden we don't have states Info, source and examples: Example 6 AJAX: Asynchronous JavaScript And XML

16 AJAX 1 61 AJAX 2 62 Different types of interactivity on the WWW: HTML/CSS + form submission + server response Fill in some information; submit; get a completely new page back Batch oriented; calls the server slow HTML/CSS + plain JavaScript Purely client based Can show / hide information, if it is already on the client: set CSS display: none or display: block Can calculate new information, if this can be done purely on the client No calls to the server What else could we want? Hover over an item show detailed info in a popup Don't reload the entire page Don't keep this information in the original page, ready to be displayed far too much information! Forum: List of topics at the top of the page Click one it is shown below the list Don't reload the entire page Plainly impossible to keep all topics in oneweb page, ready to be displayed Dynamic search box Search is performed on the server Client dynamically updates search results as you type AJAX 3 63 AJAX 4 64 Solution: Add asynchronous server requests Example: Validate text field with every key press Use XMLHttpRequest object from JavaScript Retrieve data in XML format Set a callback function, called when the request is finished Parse XML and generate suitable HTML Modify the DOM addnew information / fields Collective name for these techniques: AJAX Asynchronous JavaScript And XML Can also be used to fetch data in non XML formats AHAH: Asynchronous HTML and HTTP Server returns HTML, not XML no need to parse/generate

17 AJAX 5 65 AJAX 6 66 Form element calls validate() for every key press <input type="text" size="20" id="userid" name= userid" onkeyup="validate();"> An XMLHttpRequest object is created var req; function validate() { var idfield = document.getelementbyid("userid"); Converts to URI format (space +, 8 bit %XY) var url = "validate?userid=" + encodeuricomponent(idfield.value); // Different class names depending on browser if (typeof XMLHttpRequest!= "undefined") { req = new XMLHttpRequest(); else if (window.activexobject) { req = new ActiveXObject("Microsoft.XMLHTTP"); req.open("get", url, true); // true asynchronously // Set function to be called when a reply is received req.onreadystatechange = callback; // Send the request asynchronously returns immediately req.send(null); AJAX 7 67 AJAX 8 68 Alternative for POST function validate() { var idfield = document.getelementbyid("userid"); var url = "validate"; // No query info here var req; if (typeof XMLHttpRequest!= "undefined") { req = new XMLHttpRequest(); else if (window.activexobject) { req = new ActiveXObject("Microsoft.XMLHTTP"); req.open("post", url, true); // Tell the server how the POST data is encoded req.setrequestheader( "Content Type", "application/x www form urlencoded"); req.onreadystatechange = callback; // Query info included in send instead (still encoded) req.send("id=" + encodeuricomponent(idfield.value)); "/validate" is mapped to ValidateServlet ValidateServlet handles this just like any other request JSP pages can be used but may be less efficient Important if this is called for every key press! public class ValidateServlet extends HttpServlet { private ServletContext context; private HashMap users = new HashMap(); public void init(servletconfig config) throws ServletException { super.init(config); this.context = config.getservletcontext(); users.put("greg","account data"); users.put("duke","account data");

18 AJAX 9 69 AJAX public void doget(httpservletrequest request, HttpServletResponse response) throws IOException, ServletException { String targetid = request.getparameter("id"); // Return XML document containing reply. Must set this content type! response.setcontenttype("text/xml"); response.setheader("cache-control", "no-cache"); if ((targetid!= null) &&!users.containskey(targetid.trim())) { response.getwriter().write("<message>valid</message>"); else { response.getwriter().write("<message>invalid</message>"); The browser listens for replies in the background Calls your callback function when the request state changes State 0 = uninitialized, 1 = open, 2 = sent, 3 = receiving, 4 = loaded/done Tells you the status of the request HTTP status code: 200 = success, 401 = access denied, Possible callback function: function callback() { if (req.readystate == 4) { if (req.status == 200) { // update the DOM based on whether or not message is valid else But wait: How does the callback function get access to req? AJAX AJAX Alternative 1: Global variable var req; // Declared outside functions global variable function validate() { // Called by input field on key press req = ; req.onreadystatechange = callback; function callback() { // Called by XMLHttpRequest on state change if (req.readystate == 4) { if (req.status == 200) { // update the DOM based on whether or not message is valid else Problem: Fast typing multiple requests active simultaneously, so old requests will be overwritten (never handled) Alternative 2: Callback parameter function validate() { // Called by input field on key press var req; // Declared inside function local variable req = ; // Use an anonymous closure to pass on parameters req.onreadystatechange = function() { callback(req) ; function callback(request) { // Called by anonymous function if (request.readystate == 4) { if (request.status == 200) { // update the DOM based on whether or not message is valid else Better and cleaner solution!

19 AJAX AJAX Example callback function (for alternative 2): function parsemessagecallback(req) { var XML = req.responsexml; if (request.readystate == 4) { if (request.status == 200) { // Get the first element named message var message = XML.getElementsByTagName("message")[0]; // The <message> tag has a text child, child 0. // Its text (the node value) is the text inside <message> </>. if (message.childnodes[0].nodevalue == "invalid") { setmessage( warn, Invalid User Id"); else { setmessage( ok, Valid User Id"); else { setmessage( warn, Bad Server Response"); else { /* We don t have the complete reply yet */ Setting the message: <body> <div id="useridmessage"></div> </body> Alternative 1: Use innerhtml to set the embedded HTML function setmessage(cls, message) { var mdiv = document.getelementbyid("useridmessage"); mdiv.innerhtml = <div class=\ + cls + \ > + message + </div> ; AJAX Alternative 2: Create elements directly: function setmessage(cls, message) { var usermessageelement = document.getelementbyid("useridmessage"); usermessageelement.style.classname = cls; var messagebody = document.createtextnode(messagetext); JavaScript and Browser Compatibility // If it already has a text child, we replace it (it s from a previous call) if (usermessageelement.childnodes[0]) { usermessageelement.replacechild(messagebody, usermessageelement.childnodes[0]); else { usermessageelement.appendchild(messagebody); Jonas Kvarnström

20 Compatibility 1 77 Compatibility 2: Example 78 Browser support for HTML, DOM, CSS, JavaScript varies Older browsers simply do not support modern features Even newer browsers support partial standards, have bugs How to adapt? Sometimes, functionality exists but under different names if (typeof XMLHttpRequest!= "undefined") { req = new XMLHttpRequest(); else if (window.activexobject) { req = new ActiveXObject("Microsoft.XMLHTTP"); Sometimes, you can dowithoutcertain functionality Use it when it exists Otherwise, graceful degradation (features turned off, ) Sometimes, there s just nothing you can do with reasonable effort Many are ceasing to support IE 6 Example: Modern DOM uses getelementbyid() Netscape 4: IE 4/5: finds a node using document.layers finds a node using document.all function getelement(name) { if (document.getelementbyid) { return document.getelementbyid(name); else if (document.all) { return document.all[name]; else if (document.layers) { return document.layers[name]; Using Frameworks 79 JavaScript: The End 80 For all but the simplest applications: Use a framework! Hides browser differences (and there are many!) Provides higher level functionality Provideswell tested solutions Examples: JQuery small (23k compressed), simple, robust $("p.surprise").addclass("ohmy").show("slow"); Prototype Dojo YUI Toolkit, from Yahoo! That's it for now The ideas behind the language The connection to the DOM The concept of document manipulation A number of concrete examples Don't forget: The FireBug inspection / debugging / profiling tool

a Why JavaScript? jonkv interactivity on the web CGI JavaScript Java Applets Netscape LiveScript JavaScript 1: Example

a Why JavaScript? jonkv interactivity on the web CGI JavaScript Java Applets Netscape LiveScript JavaScript 1: Example Why JavaScript? 2 JavaScript JavaScript the language Web page manipulation with JavaScript and the DOM 1994 1995: Wanted interactivity on the web Server side interactivity: CGI Common Gateway Interface

More information

Introduction to Ajax. Sang Shin Java Technology Architect Sun Microsystems, Inc.

Introduction to Ajax. Sang Shin Java Technology Architect Sun Microsystems, Inc. Introduction to Ajax Sang Shin Java Technology Architect Sun Microsystems, Inc. sang.shin@sun.com www.javapassion.com Agenda 1.What is Rich User Experience? 2.Rich Internet Application (RIA) Technologies

More information

This course is designed for web developers that want to learn HTML5, CSS3, JavaScript and jquery.

This course is designed for web developers that want to learn HTML5, CSS3, JavaScript and jquery. HTML5/CSS3/JavaScript Programming Course Summary Description This class is designed for students that have experience with basic HTML concepts that wish to learn about HTML Version 5, Cascading Style Sheets

More information

Module7: AJAX. Click, wait, and refresh user interaction. Synchronous request/response communication model. Page-driven: Workflow is based on pages

Module7: AJAX. Click, wait, and refresh user interaction. Synchronous request/response communication model. Page-driven: Workflow is based on pages INTERNET & WEB APPLICATION DEVELOPMENT SWE 444 Fall Semester 2008-2009 (081) Module7: Objectives/Outline Objectives Outline Understand the role of Learn how to use in your web applications Rich User Experience

More information

Fall Semester (081) Module7: AJAX

Fall Semester (081) Module7: AJAX INTERNET & WEB APPLICATION DEVELOPMENT SWE 444 Fall Semester 2008-2009 (081) Module7: AJAX Dr. El-Sayed El-Alfy Computer Science Department King Fahd University of Petroleum and Minerals alfy@kfupm.edu.sa

More information

JavaScript. History. Adding JavaScript to a page. CS144: Web Applications

JavaScript. History. Adding JavaScript to a page. CS144: Web Applications JavaScript Started as a simple script in a Web page that is interpreted and run by the browser Supported by most modern browsers Allows dynamic update of a web page More generally, allows running an arbitrary

More information

JavaScript. History. Adding JavaScript to a page. CS144: Web Applications

JavaScript. History. Adding JavaScript to a page. CS144: Web Applications JavaScript Started as a simple script in a Web page that is interpreted and run by the browser Supported by most modern browsers Allows dynamic update of a web page More generally, allows running an arbitrary

More information

E ECMAScript, 21 elements collection, HTML, 30 31, 31. Index 161

E ECMAScript, 21 elements collection, HTML, 30 31, 31. Index 161 A element, 108 accessing objects within HTML, using JavaScript, 27 28, 28 activatediv()/deactivatediv(), 114 115, 115 ActiveXObject, AJAX and, 132, 140 adding information to page dynamically, 30, 30,

More information

Document Object Model (DOM) A brief introduction. Overview of DOM. .. DATA 301 Introduction to Data Science Alexander Dekhtyar..

Document Object Model (DOM) A brief introduction. Overview of DOM. .. DATA 301 Introduction to Data Science Alexander Dekhtyar.. .. DATA 301 Introduction to Data Science Alexander Dekhtyar.. Overview of DOM Document Object Model (DOM) A brief introduction Document Object Model (DOM) is a collection of platform-independent abstract

More information

710 Index Attributes, 127 action attribute, 263 assigning, bottom attribute, domain name attribute, 481 expiration date attribute, 480 8

710 Index Attributes, 127 action attribute, 263 assigning, bottom attribute, domain name attribute, 481 expiration date attribute, 480 8 INDEX Symbols = (assignment operator), 56 \ (backslash), 33 \b (backspace), 33 \" (double quotation mark), 32 \e (escape), 33 \f (form feed), 33

More information

Javascript Hierarchy Objects Object Properties Methods Event Handlers. onload onunload onblur onfocus

Javascript Hierarchy Objects Object Properties Methods Event Handlers. onload onunload onblur onfocus Javascript Hierarchy Objects Object Properties Methods Event Handlers Window Frame Location History defaultstatus frames opener parent scroll self status top window defaultstatus frames opener parent scroll

More information

Programmazione Web a.a. 2017/2018 HTML5

Programmazione Web a.a. 2017/2018 HTML5 Programmazione Web a.a. 2017/2018 HTML5 PhD Ing.Antonino Raucea antonino.raucea@dieei.unict.it 1 Introduzione HTML HTML is the standard markup language for creating Web pages. HTML stands for Hyper Text

More information

Chapter 1 Introduction to Computers and the Internet

Chapter 1 Introduction to Computers and the Internet CPET 499/ITC 250 Web Systems Dec. 6, 2012 Review of Courses Chapter 1 Introduction to Computers and the Internet The Internet in Industry & Research o E Commerce & Business o Mobile Computing and SmartPhone

More information

HTML Summary. All of the following are containers. Structure. Italics Bold. Line Break. Horizontal Rule. Non-break (hard) space.

HTML Summary. All of the following are containers. Structure. Italics Bold. Line Break. Horizontal Rule. Non-break (hard) space. HTML Summary Structure All of the following are containers. Structure Contains the entire web page. Contains information

More information

2/6/2012. Rich Internet Applications. What is Ajax? Defining AJAX. Asynchronous JavaScript and XML Term coined in 2005 by Jesse James Garrett

2/6/2012. Rich Internet Applications. What is Ajax? Defining AJAX. Asynchronous JavaScript and XML Term coined in 2005 by Jesse James Garrett What is Ajax? Asynchronous JavaScript and XML Term coined in 2005 by Jesse James Garrett http://www.adaptivepath.com/ideas/essays/archives /000385.php Ajax isn t really new, and isn t a single technology

More information

AJAX Programming Chris Seddon

AJAX Programming Chris Seddon AJAX Programming Chris Seddon seddon-software@keme.co.uk 2000-12 CRS Enterprises Ltd 1 2000-12 CRS Enterprises Ltd 2 What is Ajax? "Asynchronous JavaScript and XML" Originally described in 2005 by Jesse

More information

COPYRIGHTED MATERIAL. Contents. Chapter 1: Creating Structured Documents 1

COPYRIGHTED MATERIAL. Contents. Chapter 1: Creating Structured Documents 1 59313ftoc.qxd:WroxPro 3/22/08 2:31 PM Page xi Introduction xxiii Chapter 1: Creating Structured Documents 1 A Web of Structured Documents 1 Introducing XHTML 2 Core Elements and Attributes 9 The

More information

5. Strict mode use strict ; 6. Statement without semicolon, with semicolon 7. Keywords 8. Variables var keyword and global scope variable 9.

5. Strict mode use strict ; 6. Statement without semicolon, with semicolon 7. Keywords 8. Variables var keyword and global scope variable 9. Javascript 1) Javascript Implementation 1. The Core(ECMAScript) 2. DOM 3. BOM 2) ECMAScript describes 1. Syntax 2. Types 3. Statements 4. Keywords 5. Reserved words 6. Operators 7. Objects 3) DOM 1. Tree

More information

AJAX Basics. Welcome to AJAX Basics presentation. My name is Sang Shin. I am Java technology architect and evangelist from Sun Microsystems.

AJAX Basics. Welcome to AJAX Basics presentation. My name is Sang Shin. I am Java technology architect and evangelist from Sun Microsystems. AJAX Basics Sang Shin Java Technology Architect Sun Microsystems, Inc. sang.shin@sun.com www.javapassion.com Welcome to AJAX Basics presentation. My name is Sang Shin. I am Java technology architect and

More information

CGS 3066: Spring 2015 JavaScript Reference

CGS 3066: Spring 2015 JavaScript Reference CGS 3066: Spring 2015 JavaScript Reference Can also be used as a study guide. Only covers topics discussed in class. 1 Introduction JavaScript is a scripting language produced by Netscape for use within

More information

Lecture : 3. Practical : 2. Course Credit. Tutorial : 0. Total : 5. Course Learning Outcomes

Lecture : 3. Practical : 2. Course Credit. Tutorial : 0. Total : 5. Course Learning Outcomes Course Title Course Code WEB DESIGNING TECHNOLOGIES DCE311 Lecture : 3 Course Credit Practical : Tutorial : 0 Total : 5 Course Learning Outcomes At end of the course, students will be able to: Understand

More information

jmaki Overview Sang Shin Java Technology Architect Sun Microsystems, Inc.

jmaki Overview Sang Shin Java Technology Architect Sun Microsystems, Inc. jmaki Overview Sang Shin Java Technology Architect Sun Microsystems, Inc. sang.shin@sun.com www.javapassion.com Agenda What is and Why jmaki? jmaki widgets Using jmaki widget - List widget What makes up

More information

What Is JavaScript? A scripting language based on an object-orientated programming philosophy.

What Is JavaScript? A scripting language based on an object-orientated programming philosophy. What Is JavaScript? A scripting language based on an object-orientated programming philosophy. Each object has certain attributes. Some are like adjectives: properties. For example, an object might have

More information

COMS W3101: SCRIPTING LANGUAGES: JAVASCRIPT (FALL 2017)

COMS W3101: SCRIPTING LANGUAGES: JAVASCRIPT (FALL 2017) COMS W3101: SCRIPTING LANGUAGES: JAVASCRIPT (FALL 2017) RAMANA ISUKAPALLI RAMANA@CS.COLUMBIA.EDU 1 LECTURE-1 Course overview See http://www.cs.columbia.edu/~ramana Overview of HTML Formatting, headings,

More information

The course is supplemented by numerous hands-on labs that help attendees reinforce their theoretical knowledge of the learned material.

The course is supplemented by numerous hands-on labs that help attendees reinforce their theoretical knowledge of the learned material. Lincoln Land Community College Capital City Training Center 130 West Mason Springfield, IL 62702 217-782-7436 www.llcc.edu/cctc WA2442 Introduction to JavaScript Objectives This intensive training course

More information

COMS 469: Interactive Media II

COMS 469: Interactive Media II COMS 469: Interactive Media II Agenda Review Ch. 5: JavaScript An Object-Based Language Ch. 6: Programming the Browser Review Data Types & Variables Data Types Numeric String Boolean Variables Declaring

More information

HTML TAG SUMMARY HTML REFERENCE 18 TAG/ATTRIBUTE DESCRIPTION PAGE REFERENCES TAG/ATTRIBUTE DESCRIPTION PAGE REFERENCES MOST TAGS

HTML TAG SUMMARY HTML REFERENCE 18 TAG/ATTRIBUTE DESCRIPTION PAGE REFERENCES TAG/ATTRIBUTE DESCRIPTION PAGE REFERENCES MOST TAGS MOST TAGS CLASS Divides tags into groups for applying styles 202 ID Identifies a specific tag 201 STYLE Applies a style locally 200 TITLE Adds tool tips to elements 181 Identifies the HTML version

More information

Varargs Training & Software Development Centre Private Limited, Module: HTML5, CSS3 & JavaScript

Varargs Training & Software Development Centre Private Limited, Module: HTML5, CSS3 & JavaScript PHP Curriculum Module: HTML5, CSS3 & JavaScript Introduction to the Web o Explain the evolution of HTML o Explain the page structure used by HTML o List the drawbacks in HTML 4 and XHTML o List the new

More information

Chapter 1 Getting Started with HTML 5 1. Chapter 2 Introduction to New Elements in HTML 5 21

Chapter 1 Getting Started with HTML 5 1. Chapter 2 Introduction to New Elements in HTML 5 21 Table of Contents Chapter 1 Getting Started with HTML 5 1 Introduction to HTML 5... 2 New API... 2 New Structure... 3 New Markup Elements and Attributes... 3 New Form Elements and Attributes... 4 Geolocation...

More information

Project 3 Web Security Part 1. Outline

Project 3 Web Security Part 1. Outline Project 3 Web Security Part 1 CS155 Indrajit Indy Khare Outline Quick Overview of the Technologies HTML (and a bit of CSS) Javascript PHP Assignment Assignment Overview Example Attack 1 New to web programming?

More information

PES DEGREE COLLEGE BANGALORE SOUTH CAMPUS 1 K.M. before Electronic City, Bangalore WEB PROGRAMMING Solution Set II

PES DEGREE COLLEGE BANGALORE SOUTH CAMPUS 1 K.M. before Electronic City, Bangalore WEB PROGRAMMING Solution Set II PES DEGREE COLLEGE BANGALORE SOUTH CAMPUS 1 K.M. before Electronic City, Bangalore 560 100 WEB PROGRAMMING Solution Set II Section A 1. This function evaluates a string as javascript statement or expression

More information

! The final is at 10:30 am, Sat 6/4, in this room. ! Open book, open notes. ! No electronic devices. ! No food. ! Assignment 7 due 10pm tomorrow

! The final is at 10:30 am, Sat 6/4, in this room. ! Open book, open notes. ! No electronic devices. ! No food. ! Assignment 7 due 10pm tomorrow Announcements ECS 89 6/1! The final is at 10:30 am, Sat 6/4, in this room! Open book, open notes! No electronic devices! No food! Assignment 7 due 10pm tomorrow! No late Assignment 7 s! Fill out course

More information

UNIT -II. Language-History and Versions Introduction JavaScript in Perspective-

UNIT -II. Language-History and Versions Introduction JavaScript in Perspective- UNIT -II Style Sheets: CSS-Introduction to Cascading Style Sheets-Features- Core Syntax-Style Sheets and HTML Style Rle Cascading and Inheritance-Text Properties-Box Model Normal Flow Box Layout- Beyond

More information

Website Development with HTML5, CSS and Bootstrap

Website Development with HTML5, CSS and Bootstrap Contact Us 978.250.4983 Website Development with HTML5, CSS and Bootstrap Duration: 28 hours Prerequisites: Basic personal computer skills and basic Internet knowledge. Course Description: This hands on

More information

JavaScript and XHTML. Prof. D. Krupesha, PESIT, Bangalore

JavaScript and XHTML. Prof. D. Krupesha, PESIT, Bangalore JavaScript and XHTML Prof. D. Krupesha, PESIT, Bangalore Why is JavaScript Important? It is simple and lots of scripts available in public domain and easy to use. It is used for client-side scripting.

More information

CITS1231 Web Technologies. JavaScript Math, String, Array, Number, Debugging

CITS1231 Web Technologies. JavaScript Math, String, Array, Number, Debugging CITS1231 Web Technologies JavaScript Math, String, Array, Number, Debugging Last Lecture Introduction to JavaScript Variables Operators Conditional Statements Program Loops Popup Boxes Functions 3 This

More information

As we design and build out our HTML pages, there are some basics that we may follow for each page, site, and application.

As we design and build out our HTML pages, there are some basics that we may follow for each page, site, and application. Extra notes - Client-side Design and Development Dr Nick Hayward HTML - Basics A brief introduction to some of the basics of HTML. Contents Intro element add some metadata define a base address

More information

HTML & CSS. SWE 432, Fall 2017 Design and Implementation of Software for the Web

HTML & CSS. SWE 432, Fall 2017 Design and Implementation of Software for the Web HTML & CSS SWE 432, Fall 2017 Design and Implementation of Software for the Web HTML: HyperText Markup Language LaToza Language for describing structure of a document Denotes hierarchy of elements What

More information

UI Course HTML: (Html, CSS, JavaScript, JQuery, Bootstrap, AngularJS) Introduction. The World Wide Web (WWW) and history of HTML

UI Course HTML: (Html, CSS, JavaScript, JQuery, Bootstrap, AngularJS) Introduction. The World Wide Web (WWW) and history of HTML UI Course (Html, CSS, JavaScript, JQuery, Bootstrap, AngularJS) HTML: Introduction The World Wide Web (WWW) and history of HTML Hypertext and Hypertext Markup Language Why HTML Prerequisites Objective

More information

Module 5 JavaScript, AJAX, and jquery. Module 5. Module 5 Contains 2 components

Module 5 JavaScript, AJAX, and jquery. Module 5. Module 5 Contains 2 components Module 5 JavaScript, AJAX, and jquery Module 5 Contains 2 components Both the Individual and Group portion are due on Monday October 30 th Start early on this module One of the most time consuming modules

More information

Client vs Server Scripting

Client vs Server Scripting Client vs Server Scripting PHP is a server side scripting method. Why might server side scripting not be a good idea? What is a solution? We could try having the user download scripts that run on their

More information

HTML + CSS. ScottyLabs WDW. Overview HTML Tags CSS Properties Resources

HTML + CSS. ScottyLabs WDW. Overview HTML Tags CSS Properties Resources HTML + CSS ScottyLabs WDW OVERVIEW What are HTML and CSS? How can I use them? WHAT ARE HTML AND CSS? HTML - HyperText Markup Language Specifies webpage content hierarchy Describes rough layout of content

More information

JavaScript Introduction

JavaScript Introduction JavaScript Introduction Web Technologies I. Zsolt Tóth University of Miskolc 2016 Zsolt Tóth (UM) JavaScript Introduction 2016 1 / 31 Introduction Table of Contents 1 Introduction 2 Syntax Variables Control

More information

Index LICENSED PRODUCT NOT FOR RESALE

Index LICENSED PRODUCT NOT FOR RESALE Index LICENSED PRODUCT NOT FOR RESALE A Absolute positioning, 100 102 with multi-columns, 101 Accelerometer, 263 Access data, 225 227 Adding elements, 209 211 to display, 210 Animated boxes creation using

More information

Study Guide 2 - HTML and CSS - Chap. 6,8,10,11,12 Name - Alexia Bernardo

Study Guide 2 - HTML and CSS - Chap. 6,8,10,11,12 Name - Alexia Bernardo Study Guide 2 - HTML and CSS - Chap. 6,8,10,11,12 Name - Alexia Bernardo Note: We skipped Study Guide 1. If you d like to review it, I place a copy here: https:// people.rit.edu/~nbbigm/studyguides/sg-1.docx

More information

It is highly recommended that you are familiar with HTML and JavaScript before attempting this tutorial.

It is highly recommended that you are familiar with HTML and JavaScript before attempting this tutorial. AJAX About the Tutorial AJAX is a web development technique for creating interactive web applications. If you know JavaScript, HTML, CSS, and XML, then you need to spend just one hour to start with AJAX.

More information

8/19/2018. Web Development & Design Foundations with HTML5. Learning Objectives (1 of 2) Learning Objectives (2 of 2) What is JavaScript?

8/19/2018. Web Development & Design Foundations with HTML5. Learning Objectives (1 of 2) Learning Objectives (2 of 2) What is JavaScript? Web Development & Design Foundations with HTML5 Ninth Edition Chapter 14 A Brief Look at JavaScript and jquery Slides in this presentation contain hyperlinks. JAWS users should be able to get a list of

More information

CHAPTER 2 MARKUP LANGUAGES: XHTML 1.0

CHAPTER 2 MARKUP LANGUAGES: XHTML 1.0 WEB TECHNOLOGIES A COMPUTER SCIENCE PERSPECTIVE CHAPTER 2 MARKUP LANGUAGES: XHTML 1.0 Modified by Ahmed Sallam Based on original slides by Jeffrey C. Jackson reserved. 0-13-185603-0 HTML HELLO WORLD! Document

More information

of numbers, converting into strings, of objects creating, sorting, scrolling images using, sorting, elements of object

of numbers, converting into strings, of objects creating, sorting, scrolling images using, sorting, elements of object Index Symbols * symbol, in regular expressions, 305 ^ symbol, in regular expressions, 305 $ symbol, in regular expressions, 305 $() function, 3 icon for collapsible items, 275 > selector, 282, 375 + icon

More information

Session 11. Ajax. Reading & Reference

Session 11. Ajax. Reading & Reference Session 11 Ajax Reference XMLHttpRequest object Reading & Reference en.wikipedia.org/wiki/xmlhttprequest Specification developer.mozilla.org/en-us/docs/web/api/xmlhttprequest JavaScript (6th Edition) by

More information

Chapter 7: JavaScript for Client-Side Content Behavior

Chapter 7: JavaScript for Client-Side Content Behavior Chapter 7: JavaScript for Client-Side Content Behavior Overview and Objectives Create a rotating sequence of images (a slide show ) on the home page for our website Use a JavaScript function as the value

More information

PHP / MYSQL DURATION: 2 MONTHS

PHP / MYSQL DURATION: 2 MONTHS PHP / MYSQL HTML Introduction of Web Technology History of HTML HTML Editors HTML Doctypes HTML Heads and Basics HTML Comments HTML Formatting HTML Fonts, styles HTML links and images HTML Blocks and Layout

More information

CSC Javascript

CSC Javascript CSC 4800 Javascript See book! Javascript Syntax How to embed javascript between from an external file In an event handler URL - bookmarklet

More information

JavaScript CS 4640 Programming Languages for Web Applications

JavaScript CS 4640 Programming Languages for Web Applications JavaScript CS 4640 Programming Languages for Web Applications 1 How HTML, CSS, and JS Fit Together {css} javascript() Content layer The HTML gives the page structure and adds semantics Presentation

More information

Ajax Ajax Ajax = Asynchronous JavaScript and XML Using a set of methods built in to JavaScript to transfer data between the browser and a server in the background Reduces the amount of data that must be

More information

jquery Tutorial for Beginners: Nothing But the Goods

jquery Tutorial for Beginners: Nothing But the Goods jquery Tutorial for Beginners: Nothing But the Goods Not too long ago I wrote an article for Six Revisions called Getting Started with jquery that covered some important things (concept-wise) that beginning

More information

Code Editor. The Code Editor is made up of the following areas: Toolbar. Editable Area Output Panel Status Bar Outline. Toolbar

Code Editor. The Code Editor is made up of the following areas: Toolbar. Editable Area Output Panel Status Bar Outline. Toolbar Code Editor Wakanda s Code Editor is a powerful editor where you can write your JavaScript code for events and functions in datastore classes, attributes, Pages, widgets, and much more. Besides JavaScript,

More information

The figure below shows the Dreamweaver Interface.

The figure below shows the Dreamweaver Interface. Dreamweaver Interface Dreamweaver Interface In this section you will learn about the interface of Dreamweaver. You will also learn about the various panels and properties of Dreamweaver. The Macromedia

More information

Anatomy of an HTML document

Anatomy of an HTML document Anatomy of an HTML document hello World hello World This is the DOCTYPE declaration.

More information

Html basics Course Outline

Html basics Course Outline Html basics Course Outline Description Learn the essential skills you will need to create your web pages with HTML. Topics include: adding text any hyperlinks, images and backgrounds, lists, tables, and

More information

Using CSS for page layout

Using CSS for page layout Using CSS for page layout Advantages: Greater typographic control Style is separate from structure Potentially smaller documents Easier site maintenance Increased page layout control Increased accessibility

More information

Assignments (4) Assessment as per Schedule (2)

Assignments (4) Assessment as per Schedule (2) Specification (6) Readability (4) Assignments (4) Assessment as per Schedule (2) Oral (4) Total (20) Sign of Faculty Assignment No. 02 Date of Performance:. Title: To apply various CSS properties like

More information

CSS for Page Layout Robert K. Moniot 1

CSS for Page Layout Robert K. Moniot 1 CSS for Page Layout 2015 Robert K. Moniot 1 OBJECTIVES In this unit, you will learn: How to use style sheets for layout Controlling text flow, margins, borders, and padding Controlling visibility of elements

More information

CERTIFICATE IN WEB PROGRAMMING

CERTIFICATE IN WEB PROGRAMMING COURSE DURATION: 6 MONTHS CONTENTS : CERTIFICATE IN WEB PROGRAMMING 1. PROGRAMMING IN C and C++ Language 2. HTML/CSS and JavaScript 3. PHP and MySQL 4. Project on Development of Web Application 1. PROGRAMMING

More information

CSI 3140 WWW Structures, Techniques and Standards. Browsers and the DOM

CSI 3140 WWW Structures, Techniques and Standards. Browsers and the DOM CSI 3140 WWW Structures, Techniques and Standards Browsers and the DOM Overview The Document Object Model (DOM) is an API that allows programs to interact with HTML (or XML) documents In typical browsers,

More information

JavaScript CS 4640 Programming Languages for Web Applications

JavaScript CS 4640 Programming Languages for Web Applications JavaScript CS 4640 Programming Languages for Web Applications 1 How HTML, CSS, and JS Fit Together {css} javascript() Content layer The HTML gives the page structure and adds semantics Presentation

More information

Tizen Web UI Technologies (Tizen Ver. 2.3)

Tizen Web UI Technologies (Tizen Ver. 2.3) Tizen Web UI Technologies (Tizen Ver. 2.3) Spring 2015 Soo Dong Kim, Ph.D. Professor, Department of Computer Science Software Engineering Laboratory Soongsil University Office 02-820-0909 Mobile 010-7392-2220

More information

JavaScript: the Big Picture

JavaScript: the Big Picture JavaScript had to look like Java only less so be Java's dumb kid brother or boy-hostage sidekick. Plus, I had to be done in ten days or something worse than JavaScript would have happened.! JavaScript:

More information

Welcome Please sit on alternating rows. powered by lucid & no.dots.nl/student

Welcome Please sit on alternating rows. powered by lucid & no.dots.nl/student Welcome Please sit on alternating rows powered by lucid & no.dots.nl/student HTML && CSS Workshop Day Day two, November January 276 powered by lucid & no.dots.nl/student About the Workshop Day two: CSS

More information

READSPEAKER ENTERPRISE HIGHLIGHTING 2.5

READSPEAKER ENTERPRISE HIGHLIGHTING 2.5 READSPEAKER ENTERPRISE HIGHLIGHTING 2.5 Advanced Skinning Guide Introduction The graphical user interface of ReadSpeaker Enterprise Highlighting is built with standard web technologies, Hypertext Markup

More information

<style type="text/css"> <!-- body {font-family: Verdana, Arial, sans-serif} ***set font family for entire Web page***

<style type=text/css> <!-- body {font-family: Verdana, Arial, sans-serif} ***set font family for entire Web page*** Chapter 7 Using Advanced Cascading Style Sheets HTML is limited in its ability to define the appearance, or style, across one or mare Web pages. We use Cascading style sheets to accomplish this. Remember

More information

Introduction to using HTML to design webpages

Introduction to using HTML to design webpages Introduction to using HTML to design webpages #HTML is the script that web pages are written in. It describes the content and structure of a web page so that a browser is able to interpret and render the

More information

Session 11. Calling Servlets from Ajax. Lecture Objectives. Understand servlet response formats

Session 11. Calling Servlets from Ajax. Lecture Objectives. Understand servlet response formats Session 11 Calling Servlets from Ajax 1 Lecture Objectives Understand servlet response formats Text Xml Html JSON Understand how to extract data from the XMLHttpRequest object Understand the cross domain

More information

Index. CSS directive, # (octothorpe), intrapage links, 26

Index. CSS directive, # (octothorpe), intrapage links, 26 Holzschlag_.qxd 3/30/05 9:23 AM Page 299 Symbols @import CSS directive, 114-115 # (octothorpe), intrapage links, 26 A a element, 23, 163, 228 abbr element, 228 absolute keywords for font sizing, 144 absolute

More information

Table Basics. The structure of an table

Table Basics. The structure of an table TABLE -FRAMESET Table Basics A table is a grid of rows and columns that intersect to form cells. Two different types of cells exist: Table cell that contains data, is created with the A cell that

More information

Index. Ray Nicholus 2016 R. Nicholus, Beyond jquery, DOI /

Index. Ray Nicholus 2016 R. Nicholus, Beyond jquery, DOI / Index A addclass() method, 2 addeventlistener, 154, 156 AJAX communication, 20 asynchronous operations, 110 expected and unexpected responses, 111 HTTP, 110 web sockets, 111 AJAX requests DELETE requests,

More information

Session 4. Style Sheets (CSS) Reading & References. A reference containing tables of CSS properties

Session 4. Style Sheets (CSS) Reading & References.   A reference containing tables of CSS properties Session 4 Style Sheets (CSS) 1 Reading Reading & References en.wikipedia.org/wiki/css Style Sheet Tutorials www.htmldog.com/guides/cssbeginner/ A reference containing tables of CSS properties web.simmons.edu/~grabiner/comm244/weekthree/css-basic-properties.html

More information

Ajax HTML5 Cookies. Sessions 1A and 1B

Ajax HTML5 Cookies. Sessions 1A and 1B Ajax HTML5 Cookies Sessions 1A and 1B JavaScript Popular scripting language: Dynamic and loosely typed variables. Functions are now first-class citizens. Supports OOP. var simple = 2; simple = "I'm text

More information

Ajax Ajax Ajax = Asynchronous JavaScript and XML Using a set of methods built in to JavaScript to transfer data between the browser and a server in the background Reduces the amount of data that must be

More information

Scripting. Web Architecture and Information Management [./] Spring 2009 INFO (CCN 42509) Contents

Scripting. Web Architecture and Information Management [./] Spring 2009 INFO (CCN 42509) Contents Contents Scripting Contents Web Architecture and Information Management [./] Spring 2009 INFO 190-02 (CCN 42509) Erik Wilde, UC Berkeley School of Information [http://creativecommons.org/licenses/by/3.0/]

More information

INDEX SYMBOLS See also

INDEX SYMBOLS See also INDEX SYMBOLS @ characters, PHP methods, 125 $ SERVER global array variable, 187 $() function, 176 $F() function, 176-177 elements, Rico, 184, 187 elements, 102 containers,

More information

3 The Building Blocks: Data Types, Literals, and Variables

3 The Building Blocks: Data Types, Literals, and Variables chapter 3 The Building Blocks: Data Types, Literals, and Variables 3.1 Data Types A program can do many things, including calculations, sorting names, preparing phone lists, displaying images, validating

More information

Make a Website. A complex guide to building a website through continuing the fundamentals of HTML & CSS. Created by Michael Parekh 1

Make a Website. A complex guide to building a website through continuing the fundamentals of HTML & CSS. Created by Michael Parekh 1 Make a Website A complex guide to building a website through continuing the fundamentals of HTML & CSS. Created by Michael Parekh 1 Overview Course outcome: You'll build four simple websites using web

More information

Page Layout. 4.1 Styling Page Sections 4.2 Introduction to Layout 4.3 Floating Elements 4.4 Sizing and Positioning

Page Layout. 4.1 Styling Page Sections 4.2 Introduction to Layout 4.3 Floating Elements 4.4 Sizing and Positioning Page Layout contents of this presentation are Copyright 2009 Marty Stepp and Jessica Miller 4.1 Styling Page Sections 4.2 Introduction to Layout 4.3 Floating Elements 4.4 Sizing and Positioning 2 1 4.1

More information

Static Webpage Development

Static Webpage Development Dear Student, Based upon your enquiry we are pleased to send you the course curriculum for PHP Given below is the brief description for the course you are looking for: - Static Webpage Development Introduction

More information

Module 5 JavaScript, AJAX, and jquery. Module 5. Module 5 Contains an Individual and Group component

Module 5 JavaScript, AJAX, and jquery. Module 5. Module 5 Contains an Individual and Group component Module 5 JavaScript, AJAX, and jquery Module 5 Contains an Individual and Group component Both are due on Wednesday October 24 th Start early on this module One of the most time consuming modules in the

More information

Web UI. Survey of Front End Technologies. Web Challenges and Constraints. Desktop and mobile devices. Highly variable runtime environment

Web UI. Survey of Front End Technologies. Web Challenges and Constraints. Desktop and mobile devices. Highly variable runtime environment Web UI Survey of Front End Technologies Web UI 1 Web Challenges and Constraints Desktop and mobile devices - mouse vs. touch input, big vs. small screen Highly variable runtime environment - different

More information

COPYRIGHTED MATERIAL. Contents. Introduction. Chapter 1: Structuring Documents for the Web 1

COPYRIGHTED MATERIAL. Contents. Introduction. Chapter 1: Structuring Documents for the Web 1 Introduction Chapter 1: Structuring Documents for the Web 1 A Web of Structured Documents 1 Introducing HTML and XHTML 2 Tags and Elements 4 Separating Heads from Bodies 5 Attributes Tell Us About Elements

More information

USER GUIDE MADCAP FLARE Tables

USER GUIDE MADCAP FLARE Tables USER GUIDE MADCAP FLARE 2018 Tables Copyright 2018 MadCap Software. All rights reserved. Information in this document is subject to change without notice. The software described in this document is furnished

More information

Web Development & Design Foundations with HTML5

Web Development & Design Foundations with HTML5 1 Web Development & Design Foundations with HTML5 CHAPTER 14 A BRIEF LOOK AT JAVASCRIPT Copyright Terry Felke-Morris 2 Learning Outcomes In this chapter, you will learn how to: Describe common uses of

More information

JavaScript By: A. Mousavi & P. Broomhead SERG, School of Engineering Design, Brunel University, UK

JavaScript By: A. Mousavi & P. Broomhead SERG, School of Engineering Design, Brunel University, UK Programming for Digital Media EE1707 JavaScript By: A. Mousavi & P. Broomhead SERG, School of Engineering Design, Brunel University, UK 1 References and Sources 1. Javascript & JQuery: interactive front-end

More information

The first sample. What is JavaScript?

The first sample. What is JavaScript? Java Script Introduction JavaScript is the most popular scripting language on the internet, and works in all major browsers, such as Internet Explorer, Firefox, Chrome, Opera, and Safari. In this lecture

More information

XML in the Development of Component Systems. The Document Object Model

XML in the Development of Component Systems. The Document Object Model XML in the Development of Component Systems The Document Object Model DOM Overview Developed to support dynamic HTML Provide a standard tree interface to document structure across browsers, for use in

More information

HTML and CSS a further introduction

HTML and CSS a further introduction HTML and CSS a further introduction By now you should be familiar with HTML and CSS and what they are, HTML dictates the structure of a page, CSS dictates how it looks. This tutorial will teach you a few

More information

COMS W3101: SCRIPTING LANGUAGES: JAVASCRIPT (FALL 2018)

COMS W3101: SCRIPTING LANGUAGES: JAVASCRIPT (FALL 2018) COMS W3101: SCRIPTING LANGUAGES: JAVASCRIPT (FALL 2018) RAMANA ISUKAPALLI RAMANA@CS.COLUMBIA.EDU 1 LECTURE-1 Course overview See http://www.cs.columbia.edu/~ramana Overview of HTML Formatting, headings,

More information

A synchronous J avascript A nd X ml

A synchronous J avascript A nd X ml A synchronous J avascript A nd X ml The problem AJAX solves: How to put data from the server onto a web page, without loading a new page or reloading the existing page. Ajax is the concept of combining

More information

Introduction to HTML & CSS. Instructor: Beck Johnson Week 5

Introduction to HTML & CSS. Instructor: Beck Johnson Week 5 Introduction to HTML & CSS Instructor: Beck Johnson Week 5 SESSION OVERVIEW Review float, flex, media queries CSS positioning Fun CSS tricks Introduction to JavaScript Evaluations REVIEW! CSS Floats The

More information

JavaScript Specialist v2.0 Exam 1D0-735

JavaScript Specialist v2.0 Exam 1D0-735 JavaScript Specialist v2.0 Exam 1D0-735 Domain 1: Essential JavaScript Principles and Practices 1.1: Identify characteristics of JavaScript and common programming practices. 1.1.1: List key JavaScript

More information

NAVIGATION INSTRUCTIONS

NAVIGATION INSTRUCTIONS CLASS :: 13 12.01 2014 NAVIGATION INSTRUCTIONS SIMPLE CSS MENU W/ HOVER EFFECTS :: The Nav Element :: Styling the Nav :: UL, LI, and Anchor Elements :: Styling the UL and LI Elements CSS DROP-DOWN MENU

More information

A Brief Introduction to HTML

A Brief Introduction to HTML A P P E N D I X HTML SuMMAry J A Brief Introduction to HTML A web page is written in a language called HTML (Hypertext Markup Language). Like Java code, HTML code is made up of text that follows certain

More information