简体   繁体   English

通过javascript检测Twitter应用程序Webview

[英]Detect twitter app webview by javascript

I'm currently using the following codes to detect webview according to this post 根据这篇文章,我目前正在使用以下代码来检测Webview

var is_uiwebview = /(iPhone|iPod|iPad).*AppleWebKit(?!.*Safari)/i.test(navigator.userAgent);

It works perfectly on Fb app but not twitter app. 它在Fb应用程序上完美运行,但在twitter应用程序上却不完美。 Please help. 请帮忙。

Use this one : 使用这个:

Download origin from : this is part of visual js game engine project 下载来源: 这是Visual js游戏引擎项目的一部分

When you ask "detect webview" what you really mean. 当您询问“检测网页视图”时,您的真正意思是什么。 Are you using native app with webView (some hybrid framework - phone gap) or you just wanna to detect some iframe or adds intro html doc ? 您是将本机应用程序与webView一起使用(某种混合框架-手机差距),还是只想检测一些iframe或添加Intro html文档?

May i can figure . 我可以算一下。 You want to know is it simple browser come to page or some native app. 您想知道是简单的浏览器进入页面还是某些本机应用程序。 If you even use this like some prevent feature than is it a bad idea in security aspect. 如果您甚至像一些阻止功能一样使用它,那么在安全方面就不是一个好主意。 UserAgent data is only string easy for manipulation. UserAgent数据仅是易于操作的字符串。

"Fb app ... twitter app" ?! “ Fb​​应用... Twitter应用”?

When you precise you question you will get answer in 5 minute. 当您提出准确的问题时,您会在5分钟内得到答复。

 // Usage from web app (browser) var BROWSER = new DETECTBROWSER(); alert(BROWSER.NAME); 
 <script> function DETECTBROWSER() { var HREFF, HREFTXT = "unknown"; this.NAVIGATOR = navigator.userAgent, NAV = navigator.userAgent; var gecko, navIpad, operatablet, navIphone, navFirefox, navChrome, navOpera, navSafari, navandroid, mobile, navMozilla, Macintosh, MacOS; gecko = NAV.match(/gecko/gi); navOpera = NAV.match(/opera/gi); operatablet = NAV.match(/Tablet/gi); navIpad = NAV.match(/ipad/gi); navIphone = NAV.match(/iphone/gi); navFirefox = NAV.match(/Firefox/gi); navMozilla = NAV.match(/mozilla/gi); navChrome = NAV.match(/Chrome/gi); navSafari = NAV.match(/safari/gi); navandroid = NAV.match(/android/gi); mobile = NAV.match(/mobile/gi); Macintosh = NAV.match(/Macintosh/gi); MacOS = NAV.match(/Mac OS/gi); window["TYPEOFANDROID"] = 0; window["NOMOBILE"] = 0; var mobile = (/iphone|ipad|ipod|android|blackberry|mini|windows\\sce|palm/i.test( navigator.userAgent.toLowerCase() )); if (mobile) { var userAgent = navigator.userAgent.toLowerCase(); if ((userAgent.search("android") > -1) && (userAgent.search("mobile") > -1)) { console.log("ANDROID MOBILE 80%"); } else if ((userAgent.search("android") > -1) && !(userAgent.search("mobile") > -1)) { console.log(" ANDROID TABLET 80%") TYPEOFANDROID = 1; } } else { NOMOBILE = 1; } // FIREFOX android if (navFirefox && navandroid && TYPEOFANDROID == 0) { HREFF = "#"; HREFTXT = "mobile_firefox_android"; } // FIREFOX android T if (navFirefox && navandroid && TYPEOFANDROID == 1) { HREFF = "#"; HREFTXT = "mobile_firefox_android_tablet"; } // OPERA android if (navOpera && navandroid) { HREFF = "#"; HREFTXT = "opera_mobile_android"; }// provera // OPERA android T if (navOpera && navandroid && operatablet) { HREFF = "#"; HREFTXT = "opera_mobile_android_tablet"; }// provera // safari mobile IPHONE - safari mobile IPAD i CHROME IPAD if (navSafari) { var Iphonesafari = NAV.match(/iphone/gi); if (Iphonesafari) { HREFF = "#"; HREFTXT = "safari_mobile_iphone"; } else if (navIpad) { HREFF = "#"; HREFTXT = "mobile_safari_chrome_ipad"; } else if (navandroid) { HREFF = "#"; HREFTXT = "android_native"; } if (Macintosh && MacOS) { HREFTXT = "safari_desktop"; } } if (navChrome && navSafari && navMozilla && TYPEOFANDROID == 1) { HREFF = "#"; HREFTXT = "mobile_chrome_android_tablet"; } if (navChrome && navSafari && navMozilla && TYPEOFANDROID == 0) { HREFF = "#"; HREFTXT = "mobile_chrome_android"; } if (navChrome && TYPEOFANDROID == 0) { HREFF = "#"; HREFTXT = "chrome_browser"; } if (navMozilla && NOMOBILE == 1 && gecko && navFirefox) { HREFF = "#"; HREFTXT = "firefox_desktop"; } if (navOpera && TYPEOFANDROID == 0 && !mobile) { HREFF = "#"; HREFTXT = "opera_desktop"; } this.NAME = HREFTXT; this.NOMOBILE = NOMOBILE; } </script> 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用 PHP / Javascript 检测应用内浏览器 (WebView) - Detect in-app browser (WebView) with PHP / Javascript Android Webview位置检测javascript - Android webview location detect javascript 如何在网站中使用 jquery/javascript 检测从 web 浏览器(chrome)或 webview(移动应用程序)打开的 url? - How to detect the url opening from web browser(chrome) or webview(mobile app) using jquery/javascript in the website? 当前Twitter检测Javascript并显示页面错误 - Current Twitter detect Javascript and display page error 如果浏览器是android webview,如何使用javascript检测? - how to detect with javascript if browser is an android webview? 如果在Chrome网页浏览中加载了某个网页,如何在JavaScript中进行检测? - How to detect in JavaScript if a page was loaded in a Chrome webview? 通过 javascript 检测 ipad/iphone webview - detect ipad/iphone webview via javascript 在移动设备上检测应用内(webView 或 mini)浏览器 - Detect in-app (webView or mini) browser on mobile 网页是否可以检测到从webview应用程序访问它? - Is it possible for the webpage to detect that it is accessed from the webview app? 如何检测Android浏览器而不检测Android App(WebView)? - How to Detect Android Browsers but Not Android App (WebView)?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM