Search code examples
iphoneobjective-cxcodecordovaexternal-links

PhoneGap: Can't Load External Website


I'm trying to display a page, for example, www.google.com, in a PhoneGap application. However, I can't get the page to open in Safari, much less within PhoneGap (which is my ultimate goal).

I saw this post: PhoneGap for iPhone: problem loading external URL, and have tried from it the following:

-As described in the solution to that question, I have modified my AppDelegate.m file.

-After doing this, in part of the index.html file (created by PhoneGap), I have this code:

window.location("http://google.com");

Although the project compiles and builds fine, I see only a blank page.

I would appreciate any help, thank you.


Solution

  • window.location("http://google.com");
    

    isn't valid JavaScript. You need:

    window.location.replace("http://google.com");
    

    or

    window.location.href="http://google.com";