userAgent result different from PHP to JavaScript

my site uses browser detection on login, on login this detection is achieved using JavaScript and the verification script in PHP it works pretty good but on IE trouble begins, as the JavaScript navigator.userAgent returns

Mozilla/5.0 (Windows NT 6.3; WOW64; Trident/7.0; .NET4.0E; .NET4.0C; .NET CLR 3.5.30729; .NET CLR 2.0.50727; .NET CLR 3.0.30729; rv:11.0) like Gecko

And PHP only returns

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

What's the fix for this? If there is some. I could not find anything about this even on MS website. On Opera, FireFox and Chrome the scripts are working just fine...


Since you're sniffing browser, perhaps use the get_browser() function... but you should not rely on user agents!

It's up to the browser to determine what to set as its user agent for HTTP_USER_AGENT.

Lastly, Starting with IE11, the user-agent string no longer includes the version token.

链接地址: http://www.djcxy.com/p/51916.html

上一篇: Ajax无法获得正确的响应

下一篇: userAgent的结果不同于PHP到JavaScript