Like the example at http://jsfiddle.net/BjpWB/4/?
That example uses a click action, but the effect can be triggered by any JS action, such as window.onload. The example is generic and not specific for WP. jQuery needs to be available on the page. You could conditionally output something like the following only when the return of wp_get_post_categories() contains the category in question:
<script>
function scrollToAnchor(aid){
var aTag = jQuery("a[name='"+ aid +"']");
jQuery('html,body').animate({scrollTop: aTag.offset().top},'slow');
}
window.onload = scrollToAnchor('id3');
</script>
Thank you. @bcworkz your solution is good. I used another solution which is just to make some button or link on a page which scroll page to specific id on the bottom of page.
<a href="#id">
This button or link is clicked automatically after page loaded. I made 2 functions. 1 is just to setTimeout so 2 function can wait 3 secounds to page full load.
function function1() {
console.log('Welcome to My Console,');
}
function1();
setTimeout(function2, 3000);
function function2(){
document.getElementById("id").click();
};
Thanks for help 😉
-
This reply was modified 6 years, 9 months ago by
damians20171.
Nice! I’m glad you found something you like. You’re welcome.