我有一个简单的问题,下面我的JS功能是使用iPad打开时重定向页面。
我有一个页面mobile.abc.com,现在我要做的是重定向,如果使用ipad打开到mobile.abc.com
if ((navigator.userAgent.match(/iPad/i)) || (navigator.userAgent.match(/iPod/i))) {
location.replace("../mobile.abc.com");
}
我尝试了那个JS,但它显示错误的网址:abc.com/mobile.abc.com
有什么想法吗?
答案 0 :(得分:2)
使用:
location.replace("//mobile.abc.com");
这适用于http
或https
。