2008年2月22日

依照螢幕解析度匯入不同的 CSS 設定

<head>在這裡貼上以下原始碼</head>

<script type="text/javascript">
var headID = document.getElementsByTagName("head")[0];
var newCss = document.createElement('link');
newCss.type = "text/css";
newCss.rel = "stylesheet";
newCss.href = "css/800x600.css";
headID.appendChild(newCss);
if (screen.width > 800) {
newCss.href = "css/normal.css";
}
else {
newCss.href = "css/800x600.css";
}
</script>

紅色和綠色的部份修改為自己要用的檔案路徑即可。

沒有留言: