Explain xkcd: It's 'cause you're dumb.
< User:Waldir
Revision as of 08:16, 4 March 2013 by Waldir (Talk | contribs)

Jump to: navigation, search

Note: After saving, you may have to bypass your browser's cache to see the changes.

  • Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
  • Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
  • Internet Explorer: Hold Ctrl while clicking Refresh, or press Ctrl-F5
  • Opera: Clear the cache in Tools → Preferences

 * Create a new DOM node for the current document.
 *    Basic usage:  var mySpan = newNode('span', "Hello World!")
 *    Supports attributes and event handlers*: var mySpan = newNode('span', {style:"color: red", focus: function(){alert(this)}, id:"hello"}, "World, Hello!")
 *    Also allows nesting to create trees: var myPar = newNode('p', newNode('b',{style:"color: blue"},"Hello"), mySpan)
 * *event handlers, there are some issues with IE6 not registering event handlers on some nodes that are not yet attached to the DOM,
 * it may be safer to add event handlers later manually.
function newNode(tagname){
  var node = document.createElement(tagname);
  for( var i=1;i<arguments.length;i++ ){
    if(typeof arguments[i] == 'string'){ //Text
      node.appendChild( document.createTextNode(arguments[i]) );
    }else if(typeof arguments[i] == 'object'){ 
      if(arguments[i].nodeName){ //If it is a DOM Node
      }else{ //Attributes (hopefully)
        for(var j in arguments[i]){
          if(j == 'class'){ //Classname different because...
            node.className = arguments[i][j];
          }else if(j == 'style'){ //Style is special
   = arguments[i][j];
          }else if(typeof arguments[i][j] == 'function'){ //Basic event handlers
            newNode.addEventHandler(node, j, arguments[i][j]);
            node.setAttribute(j,arguments[i][j]); //Normal attributes
  node.addEventHandler =
    function(eventName, handler)
      { newNode.addEventHandler(this, eventName, handler); };
  return node;
newNode.addEventHandler = function(node, eventName, handler)
  try{ node.addEventListener(eventName,handler,false); //W3C
  }catch(e){try{ node.attachEvent('on'+eventName,handler,"Language"); //MSIE
  }catch(e){ node['on'+eventName]=handler; }} //Legacy

importScriptURI(' rand/addcomment.js&action=raw&ctype=text/javascript');
Personal tools


It seems you are using noscript, which is stopping our project wonderful ads from working. Explain xkcd uses ads to pay for bandwidth, and we manually approve all our advertisers, and our ads are restricted to unobtrusive images and slow animated GIFs. If you found this site helpful, please consider whitelisting us.

Want to advertise with us, or donate to us with Paypal?