Javascript
2023-05-29 11:35
33
0
将代码放入JS里面自动判断是PC端还是移动端:
function autoloadcss() {
if((navigator.userAgent.match(/(phone|pad|pod|iPhone|iPod|ios|iPad|Android|wOSBrowser|BrowserNG|WebOS)/i))) {
document.write('<link href="mobile.css" rel="stylesheet" type="text/css" media="screen" />');
}else {
document.write('<link href="pc.css" rel="stylesheet" type="text/css" media="screen" />');
}
}