我的.htaccess文件正在寫入一個「智能」cookie。如果我的頁面讀取這個cookie,它會寫入一個div。然後,我的手機CSS文件僅在用戶使用iPhone或iPod時才加載。如果用戶在Android上加載手機CSS
我的問題是,如果用戶在Android上,我該如何編輯此代碼(以下)以加載移動CSS文件?
這裏是我的page和代碼:
<meta name="viewport" content="width=device-width, user-scalable=yes" />
<link rel="stylesheet" type="text/css" href="css/mobile.css" media="only screen and (max-width: 640px)" />
<script type="text/javascript">
if (window.screen.width > 640){document.write('<meta name="viewport" content="width=980, user-scalable=yes" />')}
if((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i))){document.write('<link rel="stylesheet" type="text/css" href="css/mobile.css" media="only screen and (max-width: 640px)" />')}
</script>