第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定

js判斷當(dāng)前瀏覽器是否是源生app的webview

標(biāo)簽:
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


點(diǎn)擊查看更多內(nèi)容
1人點(diǎn)贊

若覺得本文不錯(cuò),就分享一下吧!

評(píng)論

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

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

100積分直接送

付費(fèi)專欄免費(fèi)學(xué)

大額優(yōu)惠券免費(fèi)領(lǐng)

立即參與 放棄機(jī)會(huì)
微信客服

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

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)

舉報(bào)

0/150
提交
取消