i'm creating a website which contains a smoothscroll js. Everything works fine when smoothscroll href directs to content on the same page.
But let's say that user is on webpage1 and he clicked on href which should lead and smoothscroll to "example content" on webpage2.
How to make that href link redirect the user to this page and after redirecting him, automaticlly smoothscroll to "example content".
here is an image of what i mean about that. Hope it helps in understanding my problem. https://i.postimg.cc/DzVHWsPw/image.png
I've tried using javascript load function, but without a success, perhaps i was using it the wrong way.
Here is the smoothscroll function:
(function ($) {
"use strict";
$('a.js-scroll-trigger[href*="#"]:not([href="#"])').click(function () {
if (location.pathname.replace(/^\//, '') == this.pathname.replace(/^\//, '') && location.hostname == this.hostname) {
var target = $(this.hash);
target = target.length ? target : $('[name=' + this.hash.slice(1) + ']');
if (target.length) {
$('html, body').animate({
scrollTop: (target.offset().top - 54)
}, 1000, "easeInOutExpo");
return false;
}
}
});
})(jQuery);
Here is the HTML
<a href="#info1" class="js-scroll-trigger"><button type="button">Button</button></a>
<div id="info1">Content of info1</div>
in order it to work im using jquery.min.js and jquery.easing.js
window.onloadandElement.scrollIntoView()? Here is a good S.O. article on that: stackoverflow.com/questions/5013281/…. Also see developer.mozilla.org/en-US/docs/Web/API/Element/scrollIntoView