# Redirect Error

**URL:** <https://community.hubspot.com/t/redirect-error/135556>\
**Category:** CMS Development\
**Tags:** javascript\
**Created:** [July 2, 2025, 12:17pm UTC](https://community.hubspot.com/t/redirect-error/135556 "2025-07-02T12:17:10Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Upendra1999](https://avatars.discourse-cdn.com/v4/letter/u/b4bc9f/32.png) [@Upendra1999](https://community.hubspot.com/u/Upendra1999)\
**Post date:** [July 2, 2025, 12:17pm UTC](https://community.hubspot.com/t/redirect-error/135556/1 "2025-07-02T12:17:10Z")

</div>

Dear all,

Hope this email finds you well.

We need to automatically redirect a page to a new link after 10 seconds. I attempted to add the code to the head section in the settings of the landing page, but not working.  
"Redirect Error

It looks like some code on your page caused a redirect to an unexpected URL, preventing the editor from working properly. Please wrap any JavaScript redirect code on your page with editor check conditionals. See the [knowledge base](https://developers.hubspot.com/docs/cms/guides/provide-a-good-editor-experience#how-to-use-window-hsineditor-) for more information."

 ![image (15).png](https://d2qpr2jzcazej7.cloudfront.net/original/3X/8/a/8a25ffb1146385165064bbd3de1336121508991e.png)

Thank you

---

<div class="post-metadata">

**Author:** ![BrandonWoodruff](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/brandonwoodruff/32/61045_2.png) [@BrandonWoodruff](https://community.hubspot.com/u/BrandonWoodruff)\
**Post date:** [July 2, 2025, 1:21pm UTC](https://community.hubspot.com/t/redirect-error/135556/2 "2025-07-02T13:21:05Z")

</div>

Hi there,

You’re on the right track with wanting to redirect a page after a delay, but HubSpot’s landing page editor has specific protections in place to avoid redirect loops or broken editor experiences. That’s why you’re seeing the **“Redirect Error” and the warning about wrapping your code with editor conditionals.**

To implement a timed redirect **without breaking the page editor, you need to use HubSpot’s editor check conditional around your JavaScript. Here’s a safe code snippet you can add to the Footer HTML or Head HTML of your landing page settings:**

\<script\> if (window.location.href.indexOf(‘hs\_preview’) === -1 && window.location.href.indexOf(‘content-preview’) === -1) { setTimeout(function() { window.location.href = "[https://your-new-url.com"; }, 10000); // 10 seconds = 10,000 milliseconds }](https://your-new-url.com)

\</script\>

### 

HubSpot uses special preview modes (hs\_preview or content-preview) in the editor. The if condition checks that the user is **not in preview mode before triggering the redirect. This ensures:**

- Your editor remains accessible.

- The redirect only runs for actual visitors.

---

<div class="post-metadata">

**Author:** ![Upendra1999](https://avatars.discourse-cdn.com/v4/letter/u/b4bc9f/32.png) [@Upendra1999](https://community.hubspot.com/u/Upendra1999)\
**Post date:** [July 3, 2025, 8:21am UTC](https://community.hubspot.com/t/redirect-error/135556/3 "2025-07-03T08:21:02Z")

</div>

Hi Brandon Woodruff,

Thank you for your reply.
