JavaScript Notes

  1. A rollover is an image that changes when you move the mouse pointer over it.
  2. Programs that run on the user's machine are referred to as client-side programs; programs running on the server (including things called CGIs) are called server-side programs.
  3. JavaScript controls the browser, so you can open up new windows, display alert boxes, and put custom messages in the status bar of the browser window. Because JavaScript has a set of date and time features, you can generate clocks, calendars, and timestamp documents.
  4. JavaScript can also deal with forms, set cookies, build HTML pages on the fly, and create Web-based applications.
  5. JavaScript does not allow the reading or writing of files on client machines. The only exception is that JavaScript can write to the browser's cookie file, and even then there are limitations.
  6. JavaScript does not allow the writing of files on server machines. A CGI written in a language such as Perl or PHP, or a Java program can handle the writing to the server machine.
  7. JavaScript cannot close a window that it hasn't opened.
  8. JavaScript cannot read information from an opened Web page that came from another server.
  9. Ajax = Asynchronous JavaScript and XML. Ajax is also referred to the combination of XHTML, CSS, DOM, XML, and XMLHttpRequest.
  10. The representation of the objects within the document is called the Document Object Model (DOM). JavaScript considers each of the items in the document tree to be objects, and you can use JavaScript to manipulate those objects.
  11. Common Event Handlers onabort, onblur, onchange, onclick, onerror, onfocus, onload, onmouseover, onmouseout, onselect, onsubmit, onunload.
  12. Value Types Number, String, Boolean, Null, Object, Function.
  13. Operators x+y(Numeric), x+y(String), x-y, x*y, x/y, x%y, x++, ++x, x--, --x, -x.
  14. Assignments x=y, x+=y, x-=y, x*=y, x/=y, x%=y.
  15. Comparisons x==y, x!=y, x>y, x>=y, x
  16. Tip: If you are comparing strings, be aware that "a" is greater than "A" and that "abracadabra" is less than "be".
  17. validator.w3.org for (x)html validation
  18. id is unique and sharp(#) while class is duplicated and dot(.).
  19. div is block while span is inline.
  20. <script type="text/javascript" src="script02.js"></script>
  21. Both a semicolon or a line-break can end a JavaScript statement.
  22. Multiple script tags are allowed.
  23. Functions can be called as many times as needed during the running of the script.
  24. window.onload=saySomething;
  25. document.getElementById("someIdString").innerHTML="Hello";
  26. <body onunload="saySomething('bye')">
  27. Comments are the same as in C++/java.
  28. <noscript>This page requires javascript.</noscript>
  29. window.location="http://hkuportal.hku.hk";