More JS Features


jQuery

Free, open-source JS library

There is a minified version (*/jquery.min.js) that is small but illegible

There is a normal version (*/jquery.js) as well

jQuery is javascript

Makes websites more interactive

Write less -> do more

Well documented & supported

Compatible with all browsers

jQuery Syntax

Tag Name: $("tagName") -> $("div"), $("p"), $("h1")

Tag ID: $("#id")

Tag Class: $(".className")


Cookies

Small data files stored in client/user computers

A way to store info about users and their preferences

Cookie is associated with domain name (ie. website)

When domain is revisited, cookies belonging to this domain will be retrieved by browser and sent to the server

    Issues

  • No guarantee that user will use same computer
  • Browser may have cookies turned off
  • User may delete cookies
  • Essentially no control

Cookies are saved in Name-Value pairs sepperated by ;

Expires: the default is such that the cookie is deleted when the browser is closed. The developer can determine the expiry

Domain: Domain-Name

Path: What path the cookie belongs to - Default: current page, "/" for all pages in the website

Secure: Cookie to only be transmitted Over secure Protocol as https

name=value, expires=date; path=directory; domain=domain-name; secure document.cookie = "color=blue; expires= Thu, 18 Dec 208 12:00:00 MST"

Cookie Manipulation

Creating - Assign a value to document.cookie


Timers

Run JS code after specified amount of time

Window object has 2 methods - setTimeout() & seInterval()

setTimeout() - run JS code once after a specified # of milliseconds

setInterval() - Repeatedly run JS code after a specified # of milliseconds


JSON

Text-Based Data Interchange Format

Used to Send Data (as text) back and forth to a server

Popular notation for defining objects

Written using JavaScript Object Notation

Replace XML and used with AJAX (Asynchronous ...)


Dynamic HTML

Technoolgies used to create dynamic, interactive and animated websites