Phonegap hybrid app | Webview - android

I have downloaded PhoneGap, the problem is:
When I'm trying to load a webview like in java, and it keeps opening a browser.
I want it to open the web on the same browser of the app , How do I make such a thing ?
I have tried editing the config.xml file with the following
<preference name="stay-in-webview" value="true" />
Still, it makes a jump into a web browser. really weird.

Do you want to open a Web URL at the same instance of your App? If thats the case, do not do it. It will just broke your application because a lot of elements from cordova will just have strange behavior, like BackButton or onDeviceReady.
If you want to open content from a website inside your App, use other ways, like iframes/RSS feeds or even HTML analysis (check page HTML content and filter any relevant information).
But, if you want to open it anyways, do the following:
window.location.href = "http://www.google.com";
Hope it helps. Best regards!

Related

Apache Cordova load external URL or website inside div

I am loading Website inside App using cordova.InAppBrowser.open('example.com', '_self', 'location=no,clearsessioncache=yes') and everything is works fine i.e it shows complete website mobile view inside the app, but now I am using some navigation inside assets\www\index.html file and when user will click on link the navaigation I want to load the website inside the div OR without losing the navigation.
function load_web(URL)
{
cordova.InAppBrowser.open(URL, '_self', 'location=no,clearsessioncache=yes');
}
<a href="javascript:load_web('example1.com')" >Web 1</a>
<a href="javascript:load_web('example2.com')" >Web 2</a>
In other words, you want to show a non-fullscreen external site using Cordova's InAppBrowser. You can't do this, as it will always cover the entire app window. You have to use iframes for this, but this may or may not cause your app to be rejected by the store.
Notice that iframes and InAppBrowsers are becoming more and more restricted and eventually, Google and Apple could simply delete all apps using iframes and InAppBrowsers for the so-called security concerns paranoia. (and I wouldn't blame them, for the ill-use of iframes that we see everywhere)

Phonegap disable x-frame-option in webview

i have a problem that is when i open a site like facebook.com in iframe in my phonegap app don't open because x-frame-option.
my question is can i disable checking x-frame-option from java code of cordova webview ?
or use another webview in the same activity one it top and on at down and change the url of webview ?
i'm not good on phonegap and not good in android please help me :D
Thanks all
I found the great solution in this amazing plugin
https://github.com/Wizcorp/phonegap-plugin-wizViewManager
you can add a webview to android and ios and select it position it's really great.
I would assume it isn't possible to allow it on Cordova because it is up to web view of device to handle. What you probably could do is to first download the HTML for some page with AJAX query, strip the
<meta http-equiv="X-Frame-Options" content="DENY" />
of from there and then inject the whole content into iframe. Of course this only works for single page but if that is SPA (single-page application), it might even be enough.

can I change the URL in a browser previously opened via my application

I have a code in my application to open a browser.
Sometimes I need to tell the browser to load another URL after a few seconds.
Is there a way to make the first browser to change the URL or I need to open a new one always?
Thanks,
Simon
The best way to achieve this would probably be to embed a WebView in your application, and then you can control it directly. Otherwise, as far as I know, you can't control a browser opened up via Intents. I could be wrong about that, but embedding a WebView and controlling it directly seems much more straightforward.
The WebView class reference:
http://developer.android.com/reference/android/webkit/WebView.html
Some notes on the WebView (less pertinent to what you're doing [this article pertains to writing HTML/native hybrid apps], but may have some useful information):
http://developer.android.com/guide/webapps/webview.html

How to get the content of website in phonegap?

I have to design a android,ios application for my website.I searched and find out that phonegap can be good one for that.Please provide me info that how to get the content of website in phonegap?On the first page i have buttons like home,contact etc.On click of home button,the home page from website should be shown.
PhoneGap is set of libraries like jQuery.
You normally write html pages and include javascript files from phonegap.
Check out phonegap example project.
Look, what you are talking about is .html,.css,.js files that you can easily get after saving any web page from your web-browser.
Rest you can use in the www folder of your phonegap project. And I
would rather suggest you to go for webview present in the native
android that is nothing but actually would provide you the same
functionality that you have been looking for.
---Edit---
Now as you have said that you want the home page buttons like about us etc. that would be copied via web browser and would be there for you as far as the html code is concerned but if you want it to look well on a small mobile device that you should create a responsive designed html and you should read some good articles about responsive web design. That would actually change your way of thinking about creating applications via html within mobile devices.

Phonegap navigation

I am confused about how to architecture my phonegap application.
Do I use a single-page application wherein I load relevant views using ajax ?
Or should I use many local html files and keep navigating between them using href tags ? Also, window.location seems to load the second page in a browser window, which is undesirable. I want to have whole of my app running in the same webview.
How can I stay on the same webview, while navigating between the pages using javascript ?
Try using a javascript framework like backbone or sencha touch. Jquery-mobile will work but everything will be encapsulated on one page

Categories

Resources