我正在尝试使用 PhoneGap 在 html 5 中制作移动应用程序。
为此,我将使用按钮(如菜单按钮)
当我在 google 中搜索时,我可以找到代码,但在我看来这对我不起作用。
到目前为止,我的代码与我尝试过的代码(已复制但无法运行):
http://pastebin.com/0U6ipFa7
代码有问题吗?
我是否需要更改配置中的某些内容才能正常工作?
最佳答案
document.write()
只能在您的脚本与 HTML 内联时使用,例如:
<html>
<head>
<title>Foo</title>
</head>
<body>
<script language="javascript">
document.write("bar");
</script>
</body>
</html>
在您的情况下,您应该使用 innerHTML
:
<html>
<head>
<title>Foo</title>
<script language="javascript">
function onMenuKeyDown() {
document.getElementById("barCntr").innerHTML += "<h1>Menu</h1>";
}
</script>
</head>
<body>
<div id="barCntr"></div>
</body>
</html>
关于android - HTML 5 应用程序使用 phonegap 在手机上使用按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20281960/