I need to direct the browser to scroll to the top of the page. I think iron-scroll-target-behavior
might be a good choice. But I can't find any working demos.
Can anyone locate or point me to a working demo of the iron-scroll-target-behavior element?
Instead of scroll-target-behavior
, I'm just using the platform and going with: scrollIntoView()
. Documentation
const element = document.getElementById("box");
element.scrollIntoView();
element.scrollIntoView(false);
element.scrollIntoView({block: "end"});
element.scrollIntoView({behavior: "instant", block: "end", inline: "nearest"});
Or, to scroll to the top of the page:
document.body.scrollIntoView({
behavior: "smooth",
block: "top",
})