From: Dion O. <dol...@us...> - 2005-11-21 13:29:08
|
Update of /cvsroot/magicajax/magicajax/Core In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20732/magicajax/Core Modified Files: MagicAjaxModule.cs Log Message: I've added the method IsMagicAjaxSupportedBrowser() in MagicAjaxModule.cs that return 'true' if MagicAjax supports it Index: MagicAjaxModule.cs =================================================================== RCS file: /cvsroot/magicajax/magicajax/Core/MagicAjaxModule.cs,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** MagicAjaxModule.cs 21 Nov 2005 12:18:36 -0000 1.20 --- MagicAjaxModule.cs 21 Nov 2005 13:28:50 -0000 1.21 *************** *** 135,138 **** --- 135,167 ---- /// <summary> + /// Returns if this browser is supported by MagicAjax. + /// For now (version 0.2) only IE and FireFox are supported. + /// </summary> + /// <returns></returns> + public bool IsMagicAjaxSupportedBrowser() + { + bool isSupported = false; + if (HttpContext.Current != null) + { + HttpBrowserCapabilities caps = HttpContext.Current.Request.Browser; + + if (caps.Browser != null && caps.EcmaScriptVersion.Major >=1 && caps.W3CDomVersion.Major >= 1) + { + switch (caps.Browser.ToLowerInvariant()) + { + case "ie": + isSupported = caps.MajorVersion >5 || (caps.MajorVersion == 5 && caps.MinorVersion >= 5); + break; + case "firefox": + isSupported = caps.MajorVersion >= 1; + break; + //TODO: add support for Opera, Netscape and Safari + } + } + } + return isSupported; + } + + /// <summary> /// Enables AJAX on a Page. /// </summary> *************** *** 146,153 **** if (page == null || AjaxCallHelper.IsAjaxCallForPage(page)) return; ! // Enable AJAX only for IE and Firefox, to be on the safe side. // Other browsers will get a plain postback page. ! if (page.Request.Browser.Type != "IE6" ! && page.Request.Browser.Type != "Firefox") return; --- 175,181 ---- if (page == null || AjaxCallHelper.IsAjaxCallForPage(page)) return; ! // Enable AJAX only MagicAjax-supported browsers. // Other browsers will get a plain postback page. ! if (!IsMagicAjaxSupportedBrowser()) return; |