I'd like for my page (https://fiftyallstars.com/tour.html) to load, and for the TOUR to start automatically. Right now visitors must click a button with id "starttour"

Here's what I've added so far, but it doesn't do the trick:

<script>
 $(function () {
          window.onload = $('#starttour').click();
      });
</script>

<a class="start-tour" href="#" id="starttour"><span class="two skinny" style="margin:10px 5px; width:290px; font-weight:bold; letter-spacing:4px;"><i class="fa fa-photo animated faa-pulse faa-slow"></i> Take a Detailed Tour</span></a>

Thanks for any help whatsoever.

Where is the javascript code that is attached to #starttour?

Put that in the window.onload function.

Thank you. I think the issue was that the page was loading too slowly, so I added a pause feature.

<script>
$(document).ready(function() {
  setTimeout(function() {
    $(".start-tour").trigger('click');
  }, 10000);
});
</script>

There is no reason to use a timeout because the document.ready() function waits until the DOM is ready before executing.

What if you just did something like this:

<script>
 $(function () {
          $(".start-tour").trigger('click');
      });
</script>

I try to avoid imitating user input as much as possible as, at least in the past, browsers can often change how this works for user security.

So I think it would be much better to find the actual script that the click activates as this won't get nuked at some point down the line with a browser update.

But if what you have got works, it works. So no need making it more complicated when it's working!

commented: Completely agree! +16
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.