Hello Guys,
I have this very simple HTML
:
<div> <a href="http://google.com" onclick="alert('test2');">CLICKKKKK</a></div>
The alert
is showed when user click the anchor
, but it never redirect/open the href
link on android device.
The href
is working when tested on browser (ionic serve
)
Please kindly help me, Thanks a lot
UPDATE
This is my cordova plugin list
:
cordova-plugin-console 1.0.1 "Console"
cordova-plugin-device 1.0.1 "Device"
cordova-plugin-inappbrowser 1.0.1 "InAppBrowser"
cordova-plugin-splashscreen 2.1.0 "Splashscreen"
cordova-plugin-statusbar 1.0.1 "StatusBar"
cordova-plugin-whitelist 1.0.0 "Whitelist"
ionic-plugin-keyboard 1.0.7 "Keyboard"
And i have added this in my config.xml
:
<allow-navigation href="*" />
But still the href
wont work on the android device
You need to add whitelist plugins to access external resource.learn http://docs.ionic.io/docs/cordova-whitelist
Add Cordova whitelist plugin to access external sources.
Thanks for the reply.
I have added the whitelist plugin (its there by default).
This is my cordova plugin list
:
cordova-plugin-console 1.0.1 "Console"
cordova-plugin-device 1.0.1 "Device"
cordova-plugin-inappbrowser 1.0.1 "InAppBrowser"
cordova-plugin-splashscreen 2.1.0 "Splashscreen"
cordova-plugin-statusbar 1.0.1 "StatusBar"
cordova-plugin-whitelist 1.0.0 "Whitelist"
ionic-plugin-keyboard 1.0.7 "Keyboard"
And i have added this in my config.xml
:
<allow-navigation href="*" />
But still the href
wont work on the android device
But why you keep the alert there? Can you remove the alert code and see.
To test if the anchor
actually clicked. I removed the alert
and the href
is still not working
Tried to create a fresh - blank ionic project, and add an anchor href there.
Even the href in fresh project is not working on real device, just works in the browser.
This is the full html code i used to test :
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width">
<title></title>
<link href="lib/ionic/css/ionic.css" rel="stylesheet">
<link href="css/style.css" rel="stylesheet">
<!-- IF using Sass (run gulp sass first), then uncomment below and remove the CSS includes above
<link href="css/ionic.app.css" rel="stylesheet">
-->
<!-- ionic/angularjs js -->
<script src="lib/ionic/js/ionic.bundle.js"></script>
<!-- cordova script (this will be a 404 during development) -->
<script src="cordova.js"></script>
<!-- your app's js -->
<script src="js/app.js"></script>
</head>
<body ng-app="starter">
<div> <a href="http://google.com">CLICKKKKK</a></div>
<!-- <ion-pane>
<ion-header-bar class="bar-stable">
<h1 class="title">Ionic Blank Starter</h1>
</ion-header-bar>
<ion-content>
</ion-content>
</ion-pane> -->
</body>
</html>
Really need help here, i feel stupid now
Finally found the culprit.
Its because i commented this single code in my index
:
<!-- cordova script (this will be a 404 during development) -->
<script src="cordova.js"></script>
Thanks a lot for your help