Search code examples
gwtsmartgwt

Detect if the broswer is IE in SmartGWT


I want to let the user know if the browser they are using is IE and if so, pop a warning message.

Currently I have the following right before the div IDs are loaded.

if(SC.isIE())
{
   SC.warn("You are using IE, please switch")
}

but this does not seem to work when I test it with the latest IE. Is there another way to do this (using jQuery), a better way in SmartGWT? or I am putting the isIE() at the wrong place. My first choice is doing this using smartGWT.


Solution

  • Alternatively try with plain GWT by detecting Window.Navigator.getUserAgent()

    Sample code:

    public static boolean isIEBrowser() {
        return (Window.Navigator.getUserAgent().toUpperCase().indexOf("MSIE") !=-1);
    }
    

    Note: Please have a look at User-agent string changes for Internet Explorer 11

    Please read How to detect IE11?


    IE11 on Windows 8 User agent string

    Mozilla/5.0 (Windows NT 6.3; Trident/7.0; rv:11.0) like Gecko 
    

    IE10 on Windows 8 User agent string:

    Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; Trident/6.0)