I have a simple webpage with a 3 section format that scrolls horizontally. I want the page to load on the middle section. I’ve found a couple of solutions on here but none of them have worked. Maybe I’m not doing them right. I’m not experienced in coding.
I know I can’t use anchor tags for the url because it’s for my main page so visitors have to put in the web address. There has to be a simple solution for this. Any help is appreciated. Thanks.
Advertisement
Answer
The middle section should look like this:
JavaScript
x
3
1
<section id="mainSection" tabindex="1">
2
</section>
3
And on windows load, the focus() function should work:
JavaScript
1
2
1
$("#mainSection").focus();//jQuery
2
OR
JavaScript
1
2
1
document.getElementById("mainSection").focus();//JavaScript
2