问题
I want you to open a link in my app via browser not in Appview. I ma making my html5 mobile app via xdk. I don't want to use cordova in my app as my app is heavy enogh and don't want to make it heavier because of just one link. I saw this :
<a href="#" onclick="window.open('http://www.kidzout.com', '_system');">www.kidzout.com</a>
But the problem is I must install Cordova InAppBrowser plugin for this to work. Do you have any solution without using Cordova or external plugins? Do you think is it possible at all?
回答1:
You can open a link in the native browser(Mobile Safari, Android, etc.) from within a HTML5 Mobile app using the intel.xdk API formerly AppMobi.
In the head, include a reference to the intelxdk.js file.
<script src="intelxdk.js"></script>
Use this for opening your link:
<a href="#" onclick="intel.xdk.device.launchExternal('http://www.intel.com');">Launch in Browser</a>
For more information, go to http://www.html5dev-software.intel.com/documentation/jsAPI/device/launchExternal/index.html
回答2:
If you are opening a remote URL in your webview and adding javascript is not an option, you can make a patch in native code.
Here I show the workaround for Android: https://stackoverflow.com/a/35037737/813951
来源:https://stackoverflow.com/questions/24377913/xdk-open-link-in-browser-without-using-cordova