Search code examples
javascriptcordovacordova-pluginscrosswalk

How to check if crosswalk webview?


I'm building a responsive website. When the user enters to the website through a browser such as Chrome, IE or Firefox, I want to show the links of play store and apple store. But if the user enters to the website through crosswal webview, I want to open the application.

It's possible? or it is bad idea?

Thank you.


Solution

  • Can't say if it is a good or bad idea, but you can check for CrossWalk WebView using client's user agent:

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

    Had the same question myself and saw yours. Found an answer and thought I'ld share it here as well.