Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Links in remote JQueryMobile sites in a PhoneGap app open safari

I'm having quite a peculiar problem with PhoneGap and JQuery Mobile, using the latest versions of both frameworks as of this writing.

My phonegap app has some pages 'local' to the app, and other pages that are loaded directly from a remote site. Going between the local and remote pages is fine (there is no transition but that can't exactly be helped). However, once I'm on the remote pages, any link I click on the remote pages opens Safari with the page I requested. This is not desirable functionality, as I would like it all to be within the UIWebView, and none of my links are marked with anything special that would cause Safari to open.

It gets weirder. If I then switch from Safari back to the program, the remote page I requested appears in the UIWebView, however pressing the back button leads me not to the first remote page, but the first local page.

The phonegap app right now is quite bare, very close to the default except with JQM css + js loaded. This happens even if I create a simple test app that has one local JQM page, one remote JQM page and then a remote page that is linked to from a JQM remote page.

I'm stumped. What's going on here?

like image 436
AlexMax Avatar asked Aug 19 '11 12:08

AlexMax


1 Answers

The default behavior for PhoneGap is to open external links in Safari unless they are added to the ExternalHosts property in PhoneGap.plist.

Try adding the external hosts and PhoneGap should behave correctly and load the external locations inside of the application.


(source: tumblr.com)

Here also is a post about using iFrames and ExternalHosts that could be of some help as well.

like image 127
Mark Coleman Avatar answered Nov 12 '22 02:11

Mark Coleman