How to check for Crosswalk WebView user agent?

2019-07-09 05:03发布

问题:

I need to check if a mobile user is accessing the website through a Crosswalk WebView and enable/disable some niceties.

How can I check if user is accessing using Crosswalk WebView? What is the user string for Crosswalk WebView?

回答1:

Found the correct user agent string for crosswalk webview on GitHub:

if(navigator.userAgent.toLowerCase().indexOf('crosswalk') > -1) {
    // this is crosswalk view
} else {
    // this is NOT crosswalk view
}