Browser Detection in ReactJS

前端 未结 7 1730
甜味超标
甜味超标 2020-12-04 22:20

Is there any way to detect IE browser with React and either redirect to a page or give any helpful message. I found something in JavaScript, but not sure how would I use it

相关标签:
7条回答
  • 2020-12-04 23:04

    Try:

    const isEdge = window.navigator.userAgent.indexOf('Edge') != -1
    const isIE = window.navigator.userAgent.indexOf('Trident') != -1 && !isEdge
    

    etc.

    Each browser has a distinct user agent you can check.

    These can be faked by the client of course, but in my opinion, are a more reliable long term solution.

    0 讨论(0)
提交回复
热议问题