我的请求对我来说似乎很简单,但我无法让它发挥作用。
我想将Cordova用作我现有博客的移动容器。我正在使用Windows平台进行测试。
这是我的config.xml
<?xml version='1.0' encoding='utf-8'?>
<widget id="com.testcordova" version="0.0.1" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
<name>MyAPP</name>
<access origin="*" />
<content src="http://vmorneau.me/" />
</widget>
但是在构建应用程序时它给我一个APPX1404错误。
然后我放回&#34; index.html&#34;在内容src中并进行简单的重定向(2种不同的方式)但没有任何反应。只是一个空白页面,好像什么都没有被重定向。
这是我的index.html文件:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>My Redirect</title>
</head>
<body>
<script type="text/javascript" src="cordova.js"></script>
<script type="text/javascript">
document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady() {
window.location.href="http://vmorneau.me";
//window.open("http://vmorneau.me", '_blank');
} </script>
</body>
</html>
答案 0 :(得分:0)
在index.html中,添加一个脚本来处理“deviceready”事件(这意味着你的cordova lib已经准备就绪),并在里面尝试重定向。
答案 1 :(得分:0)
我尝试过并遇到了同样的问题。当我查看控制台输出时,显示了超时错误。不知道为什么。我想你发现了一个错误。
11-08 06:02:27.169: D/CordovaWebView(1420): >>> loadUrl(http://www.johnwargo.com)
11-08 06:02:27.169: D/PluginManager(1420): init()
11-08 06:02:27.189: D/CordovaWebView(1420): >>> loadUrlNow()
11-08 06:02:27.469: D/CordovaActivity(1420): Resuming the App
11-08 06:02:27.579: D/SoftKeyboardDetect(1420): Ignore this event
11-08 06:02:27.879: I/Choreographer(1420): Skipped 82 frames! The application may be doing too much work on its main thread.
11-08 06:02:28.019: D/gralloc_goldfish(1420): Emulator without GPU emulation detected.
11-08 06:02:28.269: D/SoftKeyboardDetect(1420): Ignore this event
11-08 06:02:28.349: I/ActivityManager(378): Displayed com.johnwargo.test/.CordovaApp: +3s376ms
11-08 06:02:28.379: D/AndroidRuntime(1405): Shutting down VM
11-08 06:02:28.399: D/dalvikvm(1405): Debugger has detached; object registry had 1 entries
11-08 06:02:28.689: I/Choreographer(378): Skipped 40 frames! The application may be doing too much work on its main thread.
11-08 06:02:29.519: D/CordovaWebViewClient(1420): onPageStarted(http://www.johnwargo.com/)
11-08 06:02:29.519: D/CordovaActivity(1420): onMessage(onPageStarted,http://www.johnwargo.com/)
11-08 06:02:43.129: D/ConnectivityService(378): Sampling interval elapsed, updating statistics ..
11-08 06:02:43.289: D/ConnectivityService(378): Done.
11-08 06:02:43.289: D/ConnectivityService(378): Setting timer for 720seconds
11-08 06:02:47.229: E/CordovaWebView(1420): CordovaWebView: TIMEOUT ERROR!
11-08 06:02:48.229: W/ProcessCpuTracker(378): Skipping unknown process pid 1484
11-08 06:03:00.489: D/dalvikvm(1420): GC_FOR_ALLOC freed 317K, 10% free 3711K/4108K, paused 265ms, total 266ms
以下是适用的示例应用:
<!DOCTYPE html>
<html>
<head>
<title>Redirect</title>
<meta charset="utf-8" />
<meta name="format-detection" content="telephone=no" />
<meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width, height=device-height" />
<script type="text/javascript" charset="utf-8" src="cordova.js"></script>
<script type="text/javascript" charset="utf-8">
function onBodyLoad() {
console.log("body load");
alert("Body Load");
document.addEventListener("deviceready", onDeviceReady, false);
}
function onDeviceReady() {
console.log("Entering onDeviceReady");
window.open('http://www.johnwargo.com', '_blank');
}
</script>
</head>
<body onload="onBodyLoad()">
<h1>Redirect</h1>
<p>This is a sample Cordova application.</p>
</body>
</html>