used to create web pages. HTML elements: Head: title, base, link, style, meta, script Body: titles, paragraphs, text style, lists, tables, images, links, forms Every HTML element can be assigned with an id attribute to allow manipulation with JavaScript or CSS. <html> <head> <title>Hello World!</title> </head> <body> <h1 id="greetings">Hi</h1> <p>Minimal <b>hello world</b> page.</p> </body> </html>
<h1> vs. <font>, <b> No model-view separation CSS Zen Garden (http://www.csszengarden.com/) Preprocessors: SCSS vs LESS http://www.labnol.org/internet/learn-css/29126/
= document.getElementById("myHeader"); alert(x.innerHTML); } </script> </head> <body> <h1 id="myHeader" onclick="getValue()">This is a header</h1> <p>Click on the header to alert its value</p> </body> </html>
new XMLHttpRequest(); req.open("GET", "http://www.google.ca/search?hl=en&q=victoria", true); req.onreadystatechange = function() { if (req.readyState == 4) { if (req.status == 200) { printResultCount( req.responseText ); } } }; req.send(); } function printResultCount(data) { var str = data.match(/of about <b>(.+?)<\/b> for <b>(.+?)<\/b>/i); var obj = document.getElementById("output"); obj.innerHTML = str[1]+" results found"; } </script> </head> <body> <h1 id="myHeader" onclick="sendRequest()">This is a header</h1> <div id="output"> <p>Click on the header to use ajax</p> </div> </body> </html>
The processing of the request is idempotent The amount of form data is small You want to allow the request to be bookmarked The HTTP POST method is used when: The processing of the request changes the state of the server, such as data in a database The amount of form data is large The contents of the data should not be visible in the URL (e.g. passwords)
container provides the mechanisms to maintain states and sessions (e.g. virtual shopping cart). Cookies • The server attaches a cookie, file containing name=value pairs, with each response. • With every request the client will attach previous cookies. • In practice, the cookie holds only the unique user identifier - the session data itself is stored on the server. URL rewriting • Links will be modified to include the additional variables (e.g. the unique identifier).