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.

4
  • Yes you can, if you use a proper event handler, all you have to do is trigger it. Commented Jul 9, 2017 at 13:23
  • You can write a function call in window.load event to get a function executed on page load Commented Jul 9, 2017 at 13:24
  • Thats worked. @adeneo; function bodyOnloadHandler() { introJs().start(); } <body onload="bodyOnloadHandler()"> Thanks for comments friends Commented Jul 9, 2017 at 13:34
  • Possible duplicate of Run JavaScript function when the DOM is "ready"? Commented Jul 9, 2017 at 13:47

1 Answer 1

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

Sign up to request clarification or add additional context in comments.

3 Comments

can i add time interval this function? ex. after the 3 second started . My English not perfect sorry for this =)
Sure you can. Check out the setTimeout() and setInterval() functions. Really good tutorial here: w3schools.com/js/js_timing.asp
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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.