yuguang / fiddlesalad

An online playground with an instantly ready coding environment. Combine language preprocessors, CSS, HTML and JavaScript to create and share coding examples.
fiddlesalad.com
GNU General Public License v3.0
232 stars 80 forks source link

Works on Chrome, not in the app. Also reports missing bracket when none is missing #23

Closed FKasa closed 11 years ago

FKasa commented 11 years ago
<h1 id="title" >
    Memory
</h1>

<div id="menu" >
    <p onclick="switchTo(playMenu)" >
        Play
    </p>
</div>
<div id="playMenu" >
    GO
</div>

.current{
    display:block;
    background-color:yellow;
    color:red;
}

.off{
    display:none;
}

function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      if (oldonload) {
        oldonload();
      }
      func();
    }
  }
}
//addLoadEvent(nameOfSomeFunctionToRunOnPageLoad);
addLoadEvent(function() {
  document.getElementById("title").className = "current";
});
yuguang commented 11 years ago

You need a semicolon after the function assignment.

function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      if (oldonload) {
        oldonload();
      }
      func();
    };
  }
}
//addLoadEvent(nameOfSomeFunctionToRunOnPageLoad);
addLoadEvent(function() {
  document.getElementById("title").className = "current";
});