最近中文字幕高清中文字幕无,亚洲欧美高清一区二区三区,一本色道无码道dvd在线观看 ,一个人看的www免费高清中文字幕

為了賬號安全,請及時綁定郵箱和手機立即綁定

js判斷當前瀏覽器是否是源生app的webview

標簽:
JavaScript

有些时候,我们在开发过程中需要判断,当前页面被打开是否是处于源生的webview里面,或者NODEJS做服务器后端支持的时候,判断请求来源是否来至于源生webview里面被打开的页面请求GET/POST/..
于是写了一个轮子,用javascript的形式判断当前设备android或者ios,是不是又webview来装载页面内容 还是 浏览器(非webview)来装载页面内容。

js-is-webview

github:https://github.com/wuliqiangqiang/is-webview

use javascrupt to know it is webview ?
support node and the browser(webpack)
pass User-Agent sniffing,know the HTTP/HTTPS request is performed by a UIWebview/Webview or not.

安装

npm install js-is-webview --save

Node 服务端的用法

const isWebview = require("js-is-webview");const is_webview = new isWebview();const server = (req, res, next) => {
    - let userAgent = {
        - userAgent:req.headers['User-Agent']
    }    // if true
    if(isWebview.check(userAgent))){        //...
        next();
    }
};

浏览器 的用法

const isWebview = require("js-is-webview");
const is_webview = new isWebview();
let userAgent = {    
userAgent:navigator.userAgent
}
if(isWebview.check(userAgent))){    
//...}

API

唯一API方法,检查是否来自webview

iswebview.check({userAgent})

  • userAgent (Object.key): Browser User-Agent header string

if(isWebview.check({userAgent}))){    //...}

iswebview.check({userAgent, configObject})

  • userAgent (Object.key): Browser User-Agent header string - 浏览器标识

  • configObject (Object)

    • appName (String): the app name explicitly set in your WebView properties/settings. -在WebView属性/设置中显式设置的应用程序名称。

=====文章转载,请注明来处======

作者:_枪枪

原文链接:https://www.cnblogs.com/sheep-sheep/p/10446277.html


點擊查看更多內容
1人點贊

若覺得本文不錯,就分享一下吧!

評論

作者其他優(yōu)質文章

正在加載中
感謝您的支持,我會繼續(xù)努力的~
掃碼打賞,你說多少就多少
贊賞金額會直接到老師賬戶
支付方式
打開微信掃一掃,即可進行掃碼打賞哦
今天注冊有機會得

100積分直接送

付費專欄免費學

大額優(yōu)惠券免費領

立即參與 放棄機會
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號

舉報

0/150
提交
取消