-1

I'm working on an APP that consist of HTML and CSS using the Cordova framework. There is a button that should open a webpage. The problem is that it opens the webpage inside of the app instead of safari.

My knowledge of Objective C is extremely limited (none) so I was hoping there would be a solution using maybe Javascript.

I've looked all over the internet but couldn't find a non-Objective C solution.

The button is pretty straightforward: <a href="http://www.mywebsite.com/" target="_blank"><img src="img/button.jpg" alt="website"></a>

I thought target="_blank" might do something for me but that (unsurprisingly) didn't work.

Parrotmaster
  • 647
  • 1
  • 7
  • 27

2 Answers2

1

You can use inappbrowser plugin

http://cordova.apache.org/docs/en/3.3.0/cordova_inappbrowser_inappbrowser.md.html#InAppBrowser

Detect click on link using javascript or jquery and use this following code

window.open('http://www.google.com', '_system', 'location=yes');
AtanuCSE
  • 8,832
  • 14
  • 74
  • 112
  • I tried executing the terminal commands as specified on that page but it keeps saying "command not found". – Parrotmaster Jun 16 '14 at 07:53
  • 1
    @Parrotmaster What are you using? phonegap or cordova. If you are using phonegap then you need to use phonegap instead of cordova. I'm assuming you have used CLI before to create cordova app, so you know that you don't need this `$` before command. Try `cordova plugin add org.apache.cordova.inappbrowser` or `phonegap plugin add org.apache.cordova.inappbrowser` from inside your project folder. `cd` to your project folder and try them. This should work. – AtanuCSE Jun 16 '14 at 08:04
  • I'm using Cordova. I'll try to `cd` first. – Parrotmaster Jun 16 '14 at 08:09
  • I've tried it in all directories (xcode-projects, the project itself, the cordova folder inside the project folder) but it keeps saying "command not found". – Parrotmaster Jun 16 '14 at 08:12
  • 1
    I found out that my cordova version is 2.0.0. I'll try updating it and then use the inappbrowser plugin. – Parrotmaster Jun 16 '14 at 08:27
  • Ok I've tried updating it but it's not working out. I can't find a download for the newest version `3.5.0` and I'm failing at installing `3.4.0`. Is there any solution to my problem that works for `2.0.0`? – Parrotmaster Jun 16 '14 at 09:31
0

I found the answer to my problem:

Opening all URL's with Cordova childbrowser

Only problem is that it automatically opens twitter.com because of the share button for some unknown reason. I'm guessing this is because of an api call it's performing upon being loaded.

Parrotmaster
  • 647
  • 1
  • 7
  • 27