I am trying to open an external url link in my app which is a cordova app. Right now its presents an in app browser using modal view but it has NO back button or close button. The user essentially gets stuck when they click an external link. For instance, when someone clicks this link, enclosed in "Visit Website", an in app browser shows up, the website shows up fine, BUT there is no way to navigate back to the app, or close the in app browser. How do I go about fixing this?
<a href="http://www.sdtaproom.com/" target="_blank">Visit Website</a>
I saw that there is a solution, window.open("http://stackoverflow.com", "_system");, but I don't know how to implement it in the href code.
ANSWER (Edited): Add this code in the script tag in the head.
<script src="cordova.js"></script>
<script type="text/javascript">
window.addEventListener('load', function () {
$(document).on('click', 'a[target="_system"],a[target="_blank"]', function (e) {
e.preventDefault();
var url = this.href;
window.open(url,"_system");
});
}, false);
</script>
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…