简体   繁体   中英

Detect if PhoneGap/Cordova when loading external URL

I'm developing a PhoneGap/Cordova app which is acting as a wrapper to load and display an external URL to make a mobile website into an app using the code below:

window.open('http://www.website.com', '_self', 'location=no');

There are some elements of the mobile website which I'd like to remove on load, which aren't applicable when viewing in the app (such as "view full site").

Is there any way to detect, from the external website's JavaScript, if the page is being viewed inside a PhoneGap/Cordova app?

In the end, I used a query string parameter on the PHP page to inform it that it was being loaded inside an app.

I then used a cookie to remember it for the session and load some Javascript code if the query string is defined or if the cookie is set.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM