Check if user is using IE

后端 未结 30 1603
心在旅途
心在旅途 2020-11-22 04:34

I am calling a function like the one below by click on divs with a certain class.

Is there a way I can check when starting the function if a user is using Internet

30条回答
  •  梦毁少年i
    2020-11-22 04:57

    You can use the navigator object to detect user-navigator, you don't need jquery for it, the 4 comments below are already included so this snippet works as expected

    if (/MSIE (\d+\.\d+);/.test(navigator.userAgent) || navigator.userAgent.indexOf("Trident/") > -1 ){ 
     // Do stuff with Internet-Exploders ... :)
    }
    

    http://www.javascriptkit.com/javatutors/navigator.shtml

提交回复
热议问题