Detect android webview

前端 未结 3 1454
别那么骄傲
别那么骄傲 2021-01-21 01:45

I have an html-javascript page, and I need to detect whenever it open on web view (Like inside facebook webview, twitter webview, etc.), and if it a webview - displ

3条回答
  •  清酒与你
    2021-01-21 02:38

    I know how to do it. It is very simple. Because there is an object used by Android web view to trigger functions in its Android app via javascript. So in your js code you can use:

    if (typeof Android === "undefined") {
        // do something if is NOT a web view
    } else {
        // do something else if is a web view
    }
    

提交回复
热议问题