Section A.13. Chapter 14


A.13. Chapter 14

  1. The first thing to check is to ensure youâ??re using the DOM Level 2 event handling. If you use DOM Level 0, such as:

  2. window.onload=function;

  3. Youâ??ll overwrite the event handlers the Dojo library has assigned to this specific event.

  4. The $(â??â??) function returns whatever element has the identifier passed in as parameter to the function.

  5. Dojo requires these element attributes, but they can be added using JavaScript before Dojo needs them (after the page loads). Create a function to add the attributes, and place a call to this function in the page body just after the toolbar is loaded. In the function, set the attributes using the DOM. Hereâ??s the code Iâ??ve used for a web page:

  6. function setMenuProps(â??â??) {   var cont = document.getElementById("controller");   cont.setAttribute("itemWidth","60");   cont.setAttribute("itemHeight","100");   cont.setAttribute("itemMaxWidth", "200");   cont.setAttribute("itemMaxHeight", "300");   cont.setAttribute("orientation","horizontal");   cont.setAttribute("effectUnits","2");   cont.setAttribute("itemPadding","10");   cont.setAttribute("attachEdige","top");   cont.setAttribute("labelEdge","bottom");   cont.setAttribute("enableCrappySvgSupport","false");   var menu1 = document.getElementById("menu1");   menu1.setAttribute("onClick","load_page('http://scriptteaser.com/learningjavascript/')");   menu1.setAttribute("iconsrc","/dotty/dotty.gif");   menu1.setAttribute("caption","Learning JavaScript");   var menu2 = document.getElementById("menu2");   menu2.setAttribute("onClick","load_page('http://scriptteaser.com/threepsandr/')");   menu2.setAttribute("iconsrc","/dotty/doomed.gif");   menu2.setAttribute("caption","Three Ps and your little R, too");   var menu3 = document.getElementById("menu3");   menu3.setAttribute("onClick","load_page('http://scriptteaser.com/webservices/')");   menu3.setAttribute("iconsrc","/dotty/falling.gif");   menu3.setAttribute("caption","Web Services");   var menu4 = document.getElementById("menu4");   menu4.setAttribute("onClick","load_page('http://scriptteaser.com/misc/')");   menu4.setAttribute("iconsrc","/dotty/impatient.gif");   menu4.setAttribute("caption","Odds n Ends");   var menu5 = document.getElementById("menu5");   menu5.setAttribute("onClick","load_page('http://words.einsteinslock.com/')");   menu5.setAttribute("iconsrc","/dotty/mad.gif");   menu5.setAttribute("caption","Mad Tech Womon on the Loose");   var menu6 = document.getElementById("menu6");   menu6.setAttribute("onClick","load_page('http://scriptteaser.com/')");   menu6.setAttribute("iconsrc","/dotty/home.png");   menu6.setAttribute("caption","Home"); } Now the custom attributes can be removed from the elements. Dojo is happy and XHTML validator is happy that they're gone.

  7. Yahoo! UI creates server-side applications that provide the services for JavaScript in the pages and which make the web-service calls to the remote service. Itâ??s actually a good workaround, though performance should be monitored.

  8. This is one I canâ??t provide a answer for. I like JavaScript, and I hope that after reading this book, you do, too.




Learning JavaScript
Learning JavaScript, 2nd Edition
ISBN: 0596521871
EAN: 2147483647
Year: 2006
Pages: 151

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net