我想问一下在浏览器应用中启动外部网址会出现的问题。
这是我的代码(在intel xdk中)
<meta name="viewport" content="width=device-width, minimum-scale=1, initial-scale=1, user-scalable=no">
<link rel="stylesheet" href="css/app.css">
<!-- IMPORTANT: Do not include a weinre script tag as part of your release builds! -->
<!-- Place your remote debugging (weinre) script URL from the Test tab here, if it does not work below -->
<!-- <script src="http://debug-software.intel.com/target/target-script-min.js#insertabiglongfunkynumberfromthexdkstesttab"></script> -->
<!-- Recommended location for your JavaScript libraries -->
<!-- These library references (below) are just examples to give you the general idea... -->
<!-- <script src="lib/mc/hammer.js"></script> -->
<!-- <script src="lib/ft/fastclick.js"></script> -->
<script src="cordova.js" id="xdkJScordova_"></script>
<script src="js/app.js"></script> <!-- for your event code, see README and file comments for details -->
<script src="js/init-app.js"></script> <!-- for your init code, see README and file comments for details -->
<script src="xdk/init-dev.js"></script> <!-- normalizes device and document ready events, see file for details -->
<script type="application/javascript">
document.addEventListener("intel.xdk.device.ready",function(){
intel.xdk.device.launchExternal("http://webagate.com/demos/alia/smarty-mobile-tablet-website-template/new-1/");
},false);
</script>
</head>
<body>
<!-- <script src="http://debug-software.intel.com/target/target-script-min.js#insertabiglongfunkynumberfromthexdkstesttab"></script> -->
</body>
</html>
答案 0 :(得分:0)
英特尔XDK Native正在折旧,而是开始使用Cordova版本。 选择InAppBrowser插件并使用以下代码进行超链接。
<a href = '#' onclick=window.open('http://example.com','_blank','location=yes')>
有关更多选项,请查看插件的文档。
更新
只需将以下代码添加到app.js或自动生成的index_user_scripts.js
即可(function()
{
"use strict";
/*
hook up event handlers
*/
function register_event_handlers()
{
window.open('http://example.com', '_blank');
}
document.addEventListener("app.Ready", register_event_handlers, false);
})();
答案 1 :(得分:0)
你应该在config.xml中添加这一行,让应用程序午餐任何外部网址:<access origin="*" />
参考:https://cordova.apache.org/docs/en/4.0.0/guide_appdev_whitelist_index.md.html