home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 35 Internet / 35-Internet.zip / phoenx05.zip / phoenix / res / rdf / dom-test-6.xul < prev    next >
Extensible Markup Language  |  2002-12-10  |  1KB  |  55 lines

  1. <?xml version="1.0"?> <!-- -*- Mode: SGML; indent-tabs-mode: nil c-basic-offset: 2 -*- -->
  2. <!--
  3.  
  4. This test exercises creation of DOM elements from the XUL document,
  5. specifically, using the zombie pool.
  6.  
  7. -->
  8.  
  9. <?xml-stylesheet type="text/css" href="resource:/res/samples/xul.css"?>
  10.  
  11. <foo:foo xmlns:html="http://www.w3.org/1999/xhtml"
  12.          xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
  13.  
  14. <html:script>
  15. var elem = document.createElement('html:div');
  16. var text = document.createTextNode('Node!!!');
  17. elem.appendChild(text);
  18.  
  19. var added = false;
  20.  
  21. dump('elem.id = ' + elem.getAttribute('id') + '\n');
  22.  
  23. function addElement()
  24. {
  25.   if (! added) {
  26.     document.lastChild.appendChild(elem);
  27.     added = true;
  28.  
  29.     // should be the same as elem.id...
  30.     dump('document.lastChild.lastChild.id = ' + document.lastChild.lastChild.getAttribute('id') + '\n');
  31.   }
  32. }
  33.  
  34. function removeElement()
  35. {
  36.   if (added) {
  37.     elem.parentNode.removeChild(elem);
  38.     added = false;
  39.   }
  40. }
  41.  
  42. </html:script>
  43.  
  44.   <html:input name="b1"
  45.               type="button"
  46.               value="Add"
  47.               onclick="addElement();"/>
  48.  
  49.   <html:input name="n2"
  50.               type="button"
  51.               value="Remove"
  52.               onclick="removeElement();"/>
  53.  
  54. </foo:foo>
  55.