Recently in the mobile site, also need to be compatible with the PC side. Have not found a better way, can only use JAVASCR to determine whether the user is open on the PC side or mobile.
JS Judgment
var IsPC = function () {
var useragentinfo = Navigator.userAgent.toLowerCase ();
var Agents = new Array ("Android", "iphone", "SymbianOS", "Windows Phone", "ipad", "ipod");
var flag = true;
for (var v = 0; v < agents.length; v++) {
if (Useragentinfo.indexof (Agents[v]) > 0) {flag = false; break;}
}
return flag;
}
According to the judgment, introduce different CSS style files
var IsPC = IsPC ();
function Js_onload () {
var head=document.getelementsbytagname ("Head");
var es=document.createelement ("link");
if (!ISPC) {
es.href= ' Css/mobile.css ';
}else{
es.href= ' Css/pc.css '
}
Es.rel= "stylesheet";
Es.type= "Text/css";
Head[0].appendchild (es);
}
Js_onload ();
This is a little trouble!!! Perhaps the follow-up will find a better way to write these compatible
JS to judge the PC or the mobile side to open the Web page