代码如下:
<script type="text/javascript"><!--
function GOOGLEResize(){
alert(1);
}
var ua=navigator.userAgent.toLowerCase();
var isStrict=document.compatMode=="CSS1Compat",
isOpera=ua.indexOf("opera")>-1,
isSafari=(/webkit|khtml/).test(ua),
isIE=ua.indexOf("msie")>-1,
isIE7=ua.indexOf("msie 7")>-1,
isGecko=!isSafari&&ua.indexOf("gecko")>-1,
isBorderBox=isIE&&!isStrict,
isWindows=(ua.indexOf("windows")!=-1||ua.indexOf("win32")!=-1),
isMac=(ua.indexOf("macintosh")!=-1||ua.indexOf("mac os x")!=-1),
isLinux=(ua.indexOf("linux")!=-1),
isSecure=window.location.href.toLowerCase().indexOf("https")===0;
if(isGecko || isOpera) {
document.addEventListener("DOMContentLoaded", GOOGLEResize, false);
}else if(isIE){
document.write("<s"+'cript id="ie-deferred-loader" defer="defer" src="/'+'/:"></s'+"cript>");
var defer = document.getElementById("ie-deferred-loader");
defer.onreadystatechange = function(){
if(this.readyState == "complete"){
GOOGLEResize();
}
};
}else if(Ext.isSafari){
docReadyProcId = setInterval(function(){
var rs = document.readyState;
if(rs == "complete") {
GOOGLEResize();
}
}, 10);
}else{
window.onload=GOOGLEResize;
}
// --></script>
其中对于IE的检测很有意思。
以上代码,整理自Extjs的脚本,完全可以代替 Ext.onReady使用。
Opera
firefox
ext
ie
safari