写JS文件保存 nmobile.js()
function uaredirect(PhonePage,PCPage){
try {
if(document.getElementById("bdmark") != null){
return;
}
var urlhash = window.location.hash;
if (!urlhash.match("fromapp")){
if ((navigator.userAgent.match(/(iPhone|iPod|Android|ios|iPad)/i))) {
location.replace(murl);
}else
{
location.replace(HtmlCun);
}
}
} catch(err){}
}
主页引用并且执行
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>这是个调转界面</title>
</head>
<body>
</body>
<script src="./js/nmobile.js" type="text/javascript"></script>
<script type="text/javascript">uaredirect("https://baidu.com","https://126.com");</script>
</html>
参考: https://www.jb51.net/article/70548.htm