Script Trigger Redirect
It is an API error returned when the scripts you specify load another page, and scripts_wait_until isn’t specified. Without waiting for the new page, the screenshot would show a page that is still loading.
{ "is_successful": false, "error_code": "script_triggers_redirect", "error_message": "The specified \"scripts\" option triggers or might trigger a redirect (it loads another page, e.g. by changing `location.href`, clicking a link or submitting a form), please, specify the \"scripts_wait_until\" option. If you think it is a mistake, please, reach out at `support@screenshotone.com`.", "documentation_url": "https://screenshotone.com/docs/errors/script-triggers-redirect/"}When it’s returned
Section titled “When it’s returned”- The script contains
location.href. The API returns the error before running the script. - The script loads another page while it runs, for example, it clicks a link, submits a form, reloads the page, or goes back in history.
It isn’t returned for changes within the page, like history.pushState() or a new hash. Neither is it returned for a link that starts a download or a form that gets an empty (204) response, since the page stays. If such a response takes more than 2 seconds, though, the API can’t tell it from a slow page and returns the error.
A navigation that starts after the script has finished, for example, from a setTimeout, isn’t detected. Use scripts_wait_until for such scripts too.
How to fix
Section titled “How to fix”Set the “scripts_wait_until” option, for example, scripts_wait_until=load. The API then waits for the new page to load before taking the screenshot.
Use it only for scripts that navigate. If the script doesn’t navigate at all, neither loading another page nor changing the history or the hash, the request waits for the navigation_timeout and fails with the timeout error.
Reach out to support
Section titled “Reach out to support”If nothing helps you, please, reach out to support@screenshotone.com and we will try to help you as fast as possible.