解決辦法:
關鍵在於處理不同瀏覽器對document元素的處理,另外就是對使用的CSS是否嚴格的要做一個判斷.
Code:
01 | //取得瀏覽器視窗高度 |
02 | function getBrowserHeight() { |
03 | if ($.browser.msie) { |
04 | return document.compatMode == "CSS1Compat" ? document.documentElement.clientHeight : |
05 | document.body.clientHeight; |
06 | } else { |
07 | return self.innerHeight; |
08 | } |
09 | } |
10 | |
11 | //取得瀏覽器視窗寬度 |
12 | function getBrowserWidth() { |
13 | if ($.browser.msie) { |
14 | return document.compatMode == "CSS1Compat" ? document.documentElement.clientWidth : |
15 | document.body.clientWidth; |
16 | } else { |
17 | return self.innerWidth; |
18 | } |
19 | } |