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.
Related
I'm currently working on an application that uses the Phonegap/Cordova framework to display an online and an offline version of a website. If you're not familiar w/ this framework, it offers a simple way of creating multi-platform applications by displaying local files in a full-screen webview.
When launching the application, the Javascript integrated in the local files of the application detects if Internet access if available, and redirects the user to either another local webpage containing a full-screen iFrame of the live website, or a reduced offline version of the website (contained in the local files of the app) if no Internet connection is detected.
I would like to detect when the user logs in using the various forms on the website (being displayed inside the iFrame), but I have no way of knowing which page the user is on, or interact w/ the website content at all because of the same-origin policy.
Would it be possible though to make the Javascript from the local page (which contains the iFrame) interact w/ the Javascript from the remote page (which is being displayed in the iFrame)? This way, I would be able to obtain the login information, and save it for later use (obviously not w/o using a token system), but also it would help for another planned feature (trigger the guidance system).
Thank you.
Look into HTML5 communication, it's pretty simple and sounds like it fits your needs
http://stevehanov.ca/blog/index.php?id=109
https://developer.mozilla.org/en-US/docs/Web/API/Window/postMessage
I'll try to make a my website app, in relaty I need a top menu with some features and on the main frame I would like to see the web site, BUT I have to pharse the code for:
Create the menu in top menu with some other features
Take only the part that interests me
I don't care if I loose the original page format, I would like to parshe the original html code and work it
I tried InAppBrowser but it open the browser....I look some JSON translating but it's just for fun, I would not like spend 30$ :(
The site is made in joomla
Ideas?
Cordova isn't designed to directly load content from a website as a page.
You may be able to build a simple jQuery AJAX request for each page you want to show and then extract pieces of the resulting document.
Alternately, you could use a back-end plugin for Joomla that allows you to interface with the data from the website and then display it in an app you build using Cordova.
You could use Cordova to create a webview based app that builds the menu HTML / CSS / JS in the app on the device then for each section in the menu renders some of the content from your website inside another div in your webview and apply styles to that locally in the Cordova app. This would however make your app dependent the network to get to your website so you may also wish to consider caching content in the Cordova app for a period of time.
Ideally you would use Ajax requests back to the Joomla CMS and get the content through a JSON or XML (if you must) API then render it in the Cordova client using the Javascript framework of your choice.
I'm facing a problem on my web project. I have a custom device based on a linux which run a QT QWebPage and work with a local Apache server to display a local web application.
Which I try is to display a external page (ie : www.google.com) inside my web application. The problem is that in my application I defined my window.location to localhost in order to run my personnal webapp. When I try to load the external page, it loads it partially because some files needed by the external page are in relative link (ie css/js file) and so my Apache server try to find them locally due to my window location.
If i change the window.location to the external page the display is ok but I haven't access to my webapp.
I can't use window.open to create the other page because the architecture of the device doesn't allow multipage.
My question is : Is it possible to create an independent block in my HTML page with an other window.location than my parent page ?
Thank you in advance for your answers !
I am developing a hybrid app for Android in JavaScript and C++.
I am using MoSync and Inmobi. I receive the ads from Inmodi server, but I do not succeed to capture the cookie and open it in a default browser.
The links to GoogleStore are broken.
I am very new to this monetizing.
Can somebody please give me a code example to how to capture the dynamically passed cookie as a string in MoSync and how to pass it from my Index.html and to main.cpp?
Thanks!
I have a website www.website.com. A web user opens website.come/article.html where there is html text, images.... and javascript content (wich is different for every user).
Now my website is wordpress powered, how can i download the final version (javascript loaded and executed) of the pages opened by my users?
I want to do that because i want to know what content javascript displays for each one of them.
Can i use a php/javascript function or is there any service which do that?
You'll need a headless browser like PhantomJS to visit the page, let the javascript run and then extract the content.
There is a PHP bridge available at https://github.com/diggin/php-PhantomjsRunner, but I don't know whether it's any good.