<link rel="stylesheet" type="text/css" href=".css" media="screen">
<script type=text/javascript>
if (screen.width >= 1600)
document.getElementsByTagName("link")[0].href="style1.css" /* 桌機 */
else if (screen.width >= 1024)
document.getElementsByTagName("link")[0].href="style2.css" /* 平版 */
else if (screen.width >= 800)
document.getElementsByTagName("link")[0].href="style3.css" /* 手機 */
</script>
純用css可用底下語法切換(但是要看瀏覽器版本支援與否)
<link href="csspage1.css" media="screen and (max-device-width:2000px)" rel="stylesheet" type="text/css"></link>
<link href="csspage2.css" media="screen and (max-device-width:480px)" rel="stylesheet" type="text/css"></link>
或者惡搞切換html
<script type="text/javascript">
if ((screen.width >= 1024) && (screen.height >= 768)) {
location.href= ('switch2-1.html');
} else {
location.href= ('switch2-2.html');
}
</script>
留言列表