Phonegap标题示例代码不起作用

时间:2014-04-22 10:37:21

标签: cordova

我完全不知道' phonegap'。我已经测试了一些显示当前标题的示例代码,并且所有代码都在本地纹波仿真器中工作。

然而,当我将它部署到android时它不起作用?它什么都不做,并且没有错误写入页面。

以下代码应该只显示指向屏幕的指南针:

<!DOCTYPE html>
<html>
<head>
<title>Compass Example</title>

<script type="text/javascript" charset="utf-8" src="phonegap-1.0.0.js"></script>
<script type="text/javascript" charset="utf-8">

// Wait for PhoneGap to load
//
document.addEventListener("deviceready", onDeviceReady, false);

// PhoneGap is ready
//
function onDeviceReady() {
    navigator.compass.getCurrentHeading(onSuccess, onError);
}

// onSuccess: Get the current heading
//
function onSuccess(heading) {
    document.write('Heading: ' + heading);
}

// onError: Failed to get the heading
//
function onError() {
    document.write('Error');
}

</script>
</head>
<body>
<h1>Example</h1>
<p>getCurrentHeading</p>
</body>
</html>

代码取自: http://docs.phonegap.com/en/1.0.0/phonegap_compass_compass.md.html

我还没有沿着远程调试的路走下去,因为我希望有一些显而易见的事我做错了。

0 个答案:

没有答案
相关问题