Copy the code code as follows:
// Determine whether it is a mobile operating environment
if(/AppleWebKit.*Mobile/i.test(navigator.userAgent) || (/MIDP|SymbianOS|NOKIA|SAMSUNG|LG|NEC|TCL|Alcatel|BIRD|DBTEL|Dopod|PHILIPS|HAIER|LENOVO|MOT-|Nokia|SonyEricsson|SIE-|Amoi|ZTE/.test(navigator.userAgent ))){
if(window.location.href.indexOf("?mobile")<0){
try{
if(/Android|webOS|iPhone|iPod|BlackBerry/i.test(navigator.userAgent)){
// If the access environment is Android|webOS|iPhone|iPod|BlackBerry, load the following style
setActiveStyleSheet("style_mobile_a.css");
}
else if(/iPad/i.test(navigator.userAgent)){
// If it is determined that the access environment is iPad, load the following style
setActiveStyleSheet("style_mobile_iPad.css");
}
else{
// If it is determined that the access environment is other mobile devices, load the following styles
setActiveStyleSheet("style_mobile_other.css");
}
}
catch(e){}
}
}
else{
// If none of the above, load the following styles
setActiveStyleSheet("style_mobile_no.css");
}
//Load the style after the judgment is completed
function setActiveStyleSheet(filename){document.write("<link href="+filename+" rel=stylesheet>");}