http://dean.edwards.name/weblog/2006/06/levels/
1.

alert("Hello World");

2.

  • var WORLD = "World";
    function hello(who) {
      alert("Hello " + who);
    };
    hello(WORLD);
  • 3.

  • <button onclick="hello(WORLD)">Say Hello</button>
  • 4.

  • <button id="hello">Say Hello</button>
    var button = document.all.hello;
    button.onclick = function() {
      hello(WORLD);
    };
  • 5.

  • var button = document.getElementById("hello");
    button.addEventListener("click", function(event) {
      hello(WORLD);
    }, false);
  • 6.

  • var Hello = new Binding({
      greet: function(who) {
        alert("Hello " + who);
      },
    
      onclick: function() {
        this.greet(Hello.WORLD)
      }
    }, {
      WORLD: "World"
    });
    document.bind("#hello", Hello);
  • Advertisements