# Window.open not working

**URL:** <https://forum.ionicframework.com/t/window-open-not-working/47045>\
**Category:** ionic-v1\
**Created:** [March 21, 2016, 11:08am UTC](https://forum.ionicframework.com/t/window-open-not-working/47045 "2016-03-21T11:08:21Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![jcmag](https://avatars.discourse-cdn.com/v4/letter/j/ecb155/32.png) [@jcmag](https://forum.ionicframework.com/u/jcmag)\
**Post date:** [March 21, 2016, 11:08am UTC](https://forum.ionicframework.com/t/window-open-not-working/47045/1 "2016-03-21T11:08:21Z")

</div>

Hi,

I’m using this kind of link in my ionic app:

`<a href="#" onClick="window.open('https://google.com', '_system', 'location=yes');return false;">link</a>`

It works in a browser, and on my device with “ionic run”.  
But it doesn’t work on my client devices, who installed the app with the apk file I generated (using ionic package build android).

I have in my config.xml file:

```
<access origin="*" launch-external="yes"/>
<allow-navigation href="*"/>

```

What could be wrong?

---

<div class="post-metadata">

**Author:** ![luukschoen](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/luukschoen/32/98585_2.png) [@luukschoen](https://forum.ionicframework.com/u/luukschoen)\
**Post date:** [March 21, 2016, 11:21am UTC](https://forum.ionicframework.com/t/window-open-not-working/47045/2 "2016-03-21T11:21:48Z")

</div>

To use this functionality on your device you need the cordova inappbrowser, which can be found [here](https://github.com/apache/cordova-plugin-inappbrowser). If you use the ngCordova lib, you can also check [this](http://ngcordova.com/docs/plugins/inAppBrowser/) documentation for reference. Good luck!

---

<div class="post-metadata">

**Author:** ![jcmag](https://avatars.discourse-cdn.com/v4/letter/j/ecb155/32.png) [@jcmag](https://forum.ionicframework.com/u/jcmag)\
**Post date:** [March 21, 2016, 12:39pm UTC](https://forum.ionicframework.com/t/window-open-not-working/47045/3 "2016-03-21T12:39:02Z")

</div>

I already installed the cordova inappbrowser plugin.  
I just did another test with: $cordovaInAppBrowser.open(…), and it works on my device, with “ionic run”.  
But on another device, after an update of the app, nothing happens when I click on my links…  
I’m really stuck…

---

<div class="post-metadata">

**Author:** ![luukschoen](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/luukschoen/32/98585_2.png) [@luukschoen](https://forum.ionicframework.com/u/luukschoen)\
**Post date:** [March 21, 2016, 1:33pm UTC](https://forum.ionicframework.com/t/window-open-not-working/47045/4 "2016-03-21T13:33:26Z")

</div>

Do you get any error logs in the developers console when debugging the app on that other device?

Maybe this little example will help you out, because you have to specify some more stuff to make it 100% work.

Your HTML:  
`<a ng-click="open_link($event)" target="_system" href="{{ url }}">link to wherever you wanna go bro</a>`

Your controller function:  
`$scope.open_link = function(event) { var href = event.target.href; var browserRef = window.open(href, '_system', 'location=no,clearsessioncache=no,clearcache=no'); event.preventDefault(); }`

(btw why not using ng-click handler instead of onClick?)

---

<div class="post-metadata">

**Author:** ![luukschoen](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/luukschoen/32/98585_2.png) [@luukschoen](https://forum.ionicframework.com/u/luukschoen)\
**Post date:** [March 22, 2016, 9:43am UTC](https://forum.ionicframework.com/t/window-open-not-working/47045/5 "2016-03-22T09:43:24Z")

</div>

@jcmag did you try it out yet?

---

<div class="post-metadata">

**Author:** ![jcmag](https://avatars.discourse-cdn.com/v4/letter/j/ecb155/32.png) [@jcmag](https://forum.ionicframework.com/u/jcmag)\
**Post date:** [March 22, 2016, 9:56am UTC](https://forum.ionicframework.com/t/window-open-not-working/47045/6 "2016-03-22T09:56:40Z")

</div>

I have rebuilt the .apk file, and now it works on my customer’s devices. I think the problem was related to the config.xml file (the “allow-navigation” setting ?)

---

<div class="post-metadata">

**Author:** ![luukschoen](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/luukschoen/32/98585_2.png) [@luukschoen](https://forum.ionicframework.com/u/luukschoen)\
**Post date:** [March 22, 2016, 9:58am UTC](https://forum.ionicframework.com/t/window-open-not-working/47045/7 "2016-03-22T09:58:31Z")

</div>

Yes, the intent is important. So it could have been the issue. Glad it works now!

---

<div class="post-metadata">

**Author:** ![jcmag](https://avatars.discourse-cdn.com/v4/letter/j/ecb155/32.png) [@jcmag](https://forum.ionicframework.com/u/jcmag)\
**Post date:** [January 20, 2017, 1:29pm UTC](https://forum.ionicframework.com/t/window-open-not-working/47045/8 "2017-01-20T13:29:24Z")

</div>

a new issue appeared today:

when I run my app on my device using:  
`ionic run android`  
window.open opens the page in Chrome.

but after building an apk file, using:  
`ionic package build android`  
window.open opens the page in the inapp browser…

what could change the behavior of window.open?
