diff --git a/src/assets/js/backend_calendar_google_sync.js b/src/assets/js/backend_calendar_google_sync.js index bbc01b1f..272625de 100644 --- a/src/assets/js/backend_calendar_google_sync.js +++ b/src/assets/js/backend_calendar_google_sync.js @@ -47,7 +47,8 @@ window.BackendCalendarGoogleSync = window.BackendCalendarGoogleSync || {}; // When the browser redirects to the google user consent page the "window.document" variable // becomes "undefined" and when it comes back to the redirect URL it changes back. So check // whether the variable is undefined to avoid javascript errors. - if (windowHandle.document !== undefined) { + try { + if (windowHandle.document !== undefined) { if (windowHandle.document.URL.indexOf(redirectUrl) !== -1) { // The user has granted access to his data. windowHandle.close(); @@ -81,6 +82,11 @@ window.BackendCalendarGoogleSync = window.BackendCalendarGoogleSync || {}; }, 'json').fail(GeneralFunctions.ajaxFailureHandler); } } + } catch(Error) { + // Accessing the document object before the window is loaded throws an error, but + // it will only happen during the initialization of the window. Attaching "load" + // event handling is not possible due to CORS restrictions. + } }, 100); } else {