0

I follow this example to create a "fly to" effect.

In the example, you have to "click" a button to run the effect, i would like to run the effect when page is loaded.

I tried to "listen" the body tag with the "load" event, like this :

var flyTo = document.getElementsByTagName('body');
flyTo.addEventListener('load', function() {

It does not work.

How can I do this?

esote
  • 831
  • 12
  • 25

1 Answers1

0

You can find the answer to your question in this thread: Javascript that executes after page load

In addition if you use jQuery you can also ensure your code is executed once the page is loaded with ready:

$( document ).ready(function() { // Handler for .ready() called. });

Community
  • 1
  • 1
acanimal
  • 4,800
  • 3
  • 32
  • 41