I know you can create a link that will direct you to a section in your website like this
<a href="#result"></a>
But is it possible to set up your website that once it loads up, it automatically goes to the "#result" section? Thank you in advance!
I know you can create a link that will direct you to a section in your website like this
<a href="#result"></a>
But is it possible to set up your website that once it loads up, it automatically goes to the "#result" section? Thank you in advance!
Yes, you can do it with a bit of JavaScript. Put this in the bottom of your page:
<script>
function jumpTo(anchor){
window.location.hash = '#' + anchor;
}
jumpTo('result');
</script>
If you have jQuery, you can also make it scroll -- it can make for better usability, cause the user then knows that he is viewing a part of a bigger page:
<script>
function jumpTo(anchor){
var offset = $('a[name="' + anchor + '"]').offset().top;
$('html,body').animate({scrollTop: offset}, 'fast');
}
jumpTo('result');
</script>
Related: