if (navigator.userAgent.match(/(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i)) { // 判断是否是移动端路径,如果不是,加上移动端路径 var host = location.host + location.pathname var path = '' if (host.indexOf('/app') === -1) { if (host[host.length - 1] === '/') { path = host + 'app' } else { path = host + '/app' } // console.log(path) if (location.href.indexOf(path) === -1) { location.href="/new_/location.href.replace(host," path) } } }