我正在 PhoneGap 版本中开发一个测试应用程序。目前,我正在尝试在应用程序加载时重定向到页面。但是当我尝试这样做时,它没有重定向,而是仅停留在 index.html 页面中。我正在使用TestObject用于测试应用程序。
index.html
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" charset="utf-8">
function init() {
document.addEventListener("deviceready", onDeviceReady, true);
}
function onDeviceReady() {
alert("Device is ready");
}
</script>
</head>
<body onload="init();">
<input type="button" onclick="location.href='http://google.com';" value="Go to Google" />
Hai welcome to my app
</body>
</html>
config.xml
<?xml version="1.0" encoding="UTF-8" ?>
<widget xmlns = "http://www.w3.org/ns/widgets"
xmlns:gap = "http://phonegap.com/ns/1.0"
id = "com.mydomain.mobileApp"
versionCode = "1"
version = "1.0.0" >
<!-- versionCode is Android only -->
<!-- version is in major.minor.patch format -->
<name>My App</name>
<description>
An example for phonegap build app which wont show up in the playstore.
</description>
<author href="https://YourWebsite.com" email="yourEmail@goesHere.com">
Name Of The Author
</author>
</widget>
当我在浏览器中测试它时,单击按钮它将重定向到 http://google.com 。但是当我上传apk(从phonebuild构建)并上传到TestObject时,按钮出现了。但点击它后什么也没有发生。当我测试该应用程序时,我得到这样的结果。
谁能帮我找出问题所在。提前致谢。
最佳答案
您需要在您的应用程序中包含 cordova
也试试这个
document.addEventListener("deviceready", function(){
alert("Device ready Fire");
},true);
关于javascript - Phonegap 构建 - Javascript 不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41011196/