腳本推理: 根據瀏覽器檢測到的寬度和高度重新載入各種CSS腳本。重新加載需要重新加載其他JavaScript作爲瀏覽器的窗口正在調整大小。發現問題: IE喜歡不斷循環。IE和JavaScript:通過調整大小重新加載窗口
與其他腳本的兼容性: 瀏覽器,火狐,Safari工作
腳本使用:
<body onResize="window.location.href = window.location.href;">
有人請拿出一個更好的解決方案或建議!這必須適用於Safari,IE和FireFox。
可能其他如果邏輯基於什麼類型的瀏覽器?
SOLUTIONS下方(JQUERY):window.resize event firing in Internet Explorer
$(document).ready(function(){
var winWidth = $(window).width(),
winHeight = $(window).height();
$(window).resize(function(){
onResize = function() {
//The method which sets the LEFT css property which triggers
//window.resize again and it was a infinite loop
setWrapperPosition($mainWrapper.parent());
}
//New height and width
var winNewWidth = $(window).width(),
winNewHeight = $(window).height();
// compare the new height and width with old one
if(winWidth!=winNewWidth || winHeight!=winNewHeight)
{
window.clearTimeout(resizeTimeout);
resizeTimeout = window.setTimeout(onResize, 10);
}
//Update the width and height
winWidth = winNewWidth;
winHeight = winNewHeight;
});
});
缺陷是根據頁面大小加載CSS的設計。 – epascarello 2011-05-25 19:17:56
谷歌針對「CSS媒體查詢」... – Pointy 2011-05-25 19:18:29
另一種方法是,人工分割CSS,並在尺寸更改處理程序中的「
」或「」上設置類。 – Pointy 2011-05-25 19:19:29