CQ and Javascript redirection | Community
Skip to main content
October 16, 2015
Solved

CQ and Javascript redirection

  • October 16, 2015
  • 2 replies
  • 729 views

Good afternoon.

Im trying to write a little javascript, that detects mobile agents.

If the agent is a mobile device, redirect.

<script>
window.onload = function() {
    if(/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) {
        // If Mobile: Redirect
        window.location.replace("http://www.externalurl.com");
    }
}
</script>

Unfortunately, CQ doesnt like external URL redirection.
Is it possible, inside CQ to redirect from the client?
And if it is, how does one do it?

Kind regards
Toby

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by Sham_HC

For device detection refer and follow http://dev.day.com/docs/en/cq/5-6/developing/mobile/device-client-side-detection.html

2 replies

Sham_HC
Sham_HCAccepted solution
Level 10
October 16, 2015
October 16, 2015

Thanks, will look into that.

But the question still stands.
How does one redirect in javascript to an external URL?

Kind regards
Toby