1

Is there any way to scroll a page which has an iframe on it back to the top of that iframe when a new page loads inside the frame?

My problem is that we have a booking page and it's quite long the iframe is 1500 pixels high and generally the confirm button is about halfway down that iframe after filling out details etc but the system then sends the user to a verified by Visa/MasterCard page which is quite short and because the original page doesn't scroll back to where the iframe starts the users aren't seeing the verified box and are therefore not confirming so is there a way that every time a new page opens within the iframe my page, original page scrolls back up to where the iframe begins on the page?

1
  • 1
    something like $('iframe').contents().scrollTop(0);?
    – SpYk3HH
    Sep 5, 2014 at 13:30

1 Answer 1

3

You might try something like this:

    var iframe = document.getElementById("iframe_id");
    iframe.onload = function()
    {
        iframe.scrollIntoView();
    }
1
  • i had to select window.top.document.getElementById(...) Mar 26, 2019 at 12:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.