Naga Botak
Naga Botak

Reputation: 751

JS redirect page up one level

I have a simple question, below My JS function is to redirect the page if open using iPad.

I have a page mobile.abc.com, now what I want to do is redirect it if open using ipad to mobile.abc.com

if ((navigator.userAgent.match(/iPad/i)) || (navigator.userAgent.match(/iPod/i))) {
       location.replace("../mobile.abc.com");
    }

I tried the that JS, but it's show wrong url to be : abc.com/mobile.abc.com

Any idea ?

Upvotes: 0

Views: 333

Answers (1)

xdazz
xdazz

Reputation: 160903

Use:

location.replace("//mobile.abc.com");

This will work for both http or https.

Upvotes: 2

Related Questions