zwei1121

博客园 首页 新随笔 联系 订阅 管理
在ASP.NET AJAX中如何判断浏览器及计算其宽高
            function getClientBounds()
            
{
                
var clientWidth;
                
var clientHeight;
                
switch(Sys.Browser.agent) {
                    
case Sys.Browser.InternetExplorer:
                        clientWidth 
= document.documentElement.clientWidth;
                        clientHeight 
= document.documentElement.clientHeight;
                        
break;
                    
case Sys.Browser.Safari:
                        clientWidth 
= window.innerWidth;
                        clientHeight 
= window.innerHeight;
                        
break;
                    
case Sys.Browser.Opera:
                        clientWidth 
= Math.min(window.innerWidth, document.body.clientWidth);
                        clientHeight 
= Math.min(window.innerHeight, document.body.clientHeight);
                        
break;
                    
default:  // Sys.Browser.Firefox, etc.
                        clientWidth = Math.min(window.innerWidth, document.documentElement.clientWidth);
                        clientHeight 
= Math.min(window.innerHeight, document.documentElement.clientHeight);
                        
break;
                }


                
return new Sys.UI.Bounds(00, clientWidth, clientHeight);
            }
posted on 2007-05-25 09:19  zwei  阅读(319)  评论(0编辑  收藏  举报