0

I want to execute function that will automatically run after upon condition fulfillment (that are changing dynamically in my JavaScript code). I was trying with document.body.onload method, but I doesn't work.

document.body.onload = myfunction()

function myfunction(){
    if(start==true && moves%2==0){
            alert("Function")
    }
}
Heretic Monkey
  • 10,498
  • 6
  • 45
  • 102
pol
  • 19
  • 4

1 Answers1

0

Actually it should work, you can test this light page :

<!doctype html>
<html>
<body>

<script>
    document.body.onload = myfunction();

  function myfunction(){
      if(true){
              alert("Function");
      }
  }
</script>

</body>
</html>

Your problem is probably that "start" or "moves" are not declared or instanced on load.

iguypouf
  • 744
  • 4
  • 13