JqueryMobile + Phonegap Android Device Back Button on external links

913 Views Asked by At

I am opening a link which is not part of my domain, let's say Using this piece of code <a href="http://www.google.com" id="google"> <img src="images/google.png" ></a>'

Now when the user clicks this, my app redirects to google. I am trying to use the hardware back button on android to go back to my application.

When i press the back button, i get this message on logcat: 10-20 19:54:21.375: E/Web Console(29676): Uncaught ReferenceError: cordova is not defined at :1

What i have been able to understand from this is that when the link is redirected to google, our app has lost control of the phonegap. Is it so? I have tried using data-rel="external" with this link. But it doesn't makes any difference...

Following this, I have two problems i need help with

  • When user presses hardware back button, go back to my app.
  • When the google.com page is loading, user sees the page loading widget.
1

There are 1 best solutions below

3
On

Take a look at the Phonegap ChildBrowser plugin, it could help you with your problem, here an excerpt:

The child browser allows you to display external web pages within your PhoneGap application.

A simple use case would be:

  • Users can post links, and you don't want your users to exit your app to view the link.

This command creates a popup browser that is shown in front of your app, when the user presses the back button they are simply returned to your app.