I’ve got a script that scrolls the page to the top when a form in an iframe has submitted and new content loads into the iframe.
document.querySelector("iframe").addEventListener("load",
function() {
window.scrollTo({
top: 0,
left: 0,
behavior: 'smooth'
});
});
Instead of scrolling to the top I need the page to scroll to a particular element with a specific ID. How would that code need to change?
I’m not very knowledgable with JS, so would really appreciate the full code needed. Thank you so much!