This question is locked. New answers and comments are not allowed.
Hi,
I'm using Icenium with jQuery Mobile and Cordova and want a link on one of the pages to open in the device's web browser instead of in the "app" itself. The code below shows what I'm trying. The most annoying thing of all is that it works fine in Icenium Ion, but fails when the app is published through iTunes.
Can anybody suggest what I'm doing wrong or how to set this up correctly? Is the difference between Ion and "my app" relevant? Perhaps there's some permission I need to set in Icenium Mist when building the app? (at the moment I have not ticked any of the checkboxes for plugins)
HTML of the link itself:
<div id="home" data-role="page">
<div data-role="content">
...page content in here...
<div data-role="footer" data-position="fixed" data-id="common-footer" data-theme="a">
<div data-role="navbar">
<ul>
... other links ...
<li><a href="http://www.example.com" data-icon="link" class="external-link">Website</a></li>
</ul>
</div>
</div>
</div>
JavaScript to change the link's behaviour:
$(document).ready(function(){
$('.external-link').on("click", function(e) {
var targetURL = $(this).attr("href");
var ua = navigator.userAgent.toLowerCase();
if (ua.indexOf("android") > -1) {
e.preventDefault();
navigator.app.loadUrl(targetURL); // Android only
return false;
} else if (ua.indexOf("ipod")>-1 || ua.indexOf("iphone")>-1 || ua.indexOf("ipad")>-1) {
e.preventDefault();
window.open(targetURL, "_system");
return false;
}
});
});
Thanks in advance for any help that can be shed on this!
Christian
(As a side note, the reason I want to open it in the app's browser is so that (a) it has a 'window' which allows pinch zoom, when the app itself is fixed and (b) so there's a way "back" to the app.)
I'm using Icenium with jQuery Mobile and Cordova and want a link on one of the pages to open in the device's web browser instead of in the "app" itself. The code below shows what I'm trying. The most annoying thing of all is that it works fine in Icenium Ion, but fails when the app is published through iTunes.
Can anybody suggest what I'm doing wrong or how to set this up correctly? Is the difference between Ion and "my app" relevant? Perhaps there's some permission I need to set in Icenium Mist when building the app? (at the moment I have not ticked any of the checkboxes for plugins)
HTML of the link itself:
<div id="home" data-role="page">
<div data-role="content">
...page content in here...
<div data-role="footer" data-position="fixed" data-id="common-footer" data-theme="a">
<div data-role="navbar">
<ul>
... other links ...
<li><a href="http://www.example.com" data-icon="link" class="external-link">Website</a></li>
</ul>
</div>
</div>
</div>
JavaScript to change the link's behaviour:
$(document).ready(function(){
$('.external-link').on("click", function(e) {
var targetURL = $(this).attr("href");
var ua = navigator.userAgent.toLowerCase();
if (ua.indexOf("android") > -1) {
e.preventDefault();
navigator.app.loadUrl(targetURL); // Android only
return false;
} else if (ua.indexOf("ipod")>-1 || ua.indexOf("iphone")>-1 || ua.indexOf("ipad")>-1) {
e.preventDefault();
window.open(targetURL, "_system");
return false;
}
});
});
Thanks in advance for any help that can be shed on this!
Christian
(As a side note, the reason I want to open it in the app's browser is so that (a) it has a 'window' which allows pinch zoom, when the app itself is fixed and (b) so there's a way "back" to the app.)