0
 <div  class="scroll-btn hidden-sm hidden-xs wow bounceInDown" data-wow-delay="1.4s">
     <a id="introjs" href="javascript:void(0)" onclick="introJs().start();">
         <span class="mouse">
         <span class="weel">
         <span></span>
         </span>
         </span>
     </a>
 </div>

Can i start to onclick funtion automatic on page load or on page ready. Not on click #introjs element.

TufanCPN
  • 13
  • 1
  • 5
  • Yes you can, if you use a proper event handler, all you have to do is trigger it. – adeneo Jul 09 '17 at 13:23
  • You can write a function call in window.load event to get a function executed on page load – thiru Jul 09 '17 at 13:24
  • Thats worked. @adeneo; function bodyOnloadHandler() { introJs().start(); } Thanks for comments friends – TufanCPN Jul 09 '17 at 13:34
  • Possible duplicate of [Run JavaScript function when the DOM is "ready"?](https://stackoverflow.com/questions/7992342/run-javascript-function-when-the-dom-is-ready) – t.niese Jul 09 '17 at 13:47

1 Answers1

1

Either use JQuery's $(document).ready()

or without JQuery, something like this would work in about 98% of browsers:

document.addEventListener("DOMContentLoaded", function(event) { 
  //do work
});

There's a great answer here with a bit more detail on the subject https://stackoverflow.com/a/800010/8055700

dbl4k
  • 71
  • 6
  • can i add time interval this function? ex. after the 3 second started . My English not perfect sorry for this =) – TufanCPN Jul 09 '17 at 13:50
  • Sure you can. Check out the setTimeout() and setInterval() functions. Really good tutorial here: https://www.w3schools.com/js/js_timing.asp – dbl4k Jul 09 '17 at 13:57
  • 1
    You should avoid to link to w3schools, even after years they still suffer from inaccuracies and lack important informations. E.g. they write `[...]The setTimeout() and setInterval() are both methods of the HTML DOM Window object.[...]` which is not essential wrong, but they are both utility _functions_ (not _methods_) exposed by the `window` object, or nowadays are part of the window or webworker global scope. – t.niese Jul 09 '17 at 14:13