diff --git a/formio/static/src/js/formio_form_container.js b/formio/static/src/js/formio_form_container.js index 50f248e0..f0ed4c49 100644 --- a/formio/static/src/js/formio_form_container.js +++ b/formio/static/src/js/formio_form_container.js @@ -21,7 +21,13 @@ $(document).ready(function() { window.location = saveDraftDoneUrl; } else if (event.origin == baseUrl && msg == 'formioScrollIntoView' && scrollIntoViewSelector) { - document.querySelector(scrollIntoViewSelector, window.parent.parent.document).scrollIntoView(); + let targetElement = document.querySelector(scrollIntoViewSelector); + if (!targetElement && window.parent && window.parent.parent) { + targetElement = window.parent.parent.document.querySelector(scrollIntoViewSelector); + } + if (targetElement) { + targetElement.scrollIntoView(); + } } else if (event.origin == baseUrl && msg == 'formioScrollTop') { window.parent.scrollTo(0, 0);