[英]javascript in phonegap for single page application
I try to convert my web application into Android application, using Phonegap. 我尝试使用Phonegap将Web应用程序转换为Android应用程序。
The application is very simple: html, javascript, css. 该应用程序非常简单:html,javascript,css。 Logically it is a single page, which content is changed by a simple javascript code (no any external libraries).
从逻辑上讲,它是一个页面,其内容由一个简单的javascript代码更改(没有任何外部库)。
The problem is that, javascript works only for items present on the original page. 问题是,javascript仅适用于原始页面上显示的项目。 If an item appeared as a result of a javascript function and has another javascript function assigned to it, that another function never be executed.
如果某个项目是由于javascript函数而出现的,并且为其分配了另一个javascript函数,则该另一个函数将永远不会执行。
What could be the reason? 可能是什么原因? And how can I improve the situation?
我该如何改善这种情况?
Update: 更新:
the problem is that in case one see the app in a desktop browser window form1 property of the document is defined (it appears on step3), for a mobile app it is not so. 问题是,如果有人在桌面浏览器窗口中看到该应用程序,则定义了该文档的form1属性(它出现在step3上),而对于移动应用程序却并非如此。
Demo: 演示:
<html>
<head>
<script type="text/javascript">
document.onclick = function( whichOne ){
whichOne = whichOne ? whichOne : window.event;
thisButton = whichOne.target ? whichOne.target : whichOne.srcElement;
if (thisButton.name) {
if (thisButton.value == 'Submit') {
if (undefined != document.form1){
alert("yes form1");
}
else {
alert("no form1");
}
}
else if (thisButton.name == 'b1') {
var iner ='<center>step 2</center>';
un1(thisButton.title,iner);
var oid=thisButton.title;
iner = t4a(oid,thisButton.name);
setTimeout( function() { un1(oid,iner);},1000);
}
}
}
function un1(id,iner){
var ele = document.getElementById(id);
ele.innerHTML = iner;
}
function t4a (id,ara){
var i;
var out="<form name='form1'><center>step 3<table border='1'>";
for (i=0;i < 2;i++){
out +="<tr><td align='left'>"+i+".</td><td align='right'><input type='text' name='f"+i+"'></td></tr>";
}
out+="</table><input type='button' name='a"+ara+"' title='"+id+"' value='Submit'
></center></form>";
return out;
}
</script>
</head>
<body>
<center>
<form >
<div id ="b1">
<input type="button" name="b1" title="b1" value="Butt">
</div>
</form>
</center>
</body>
</html>
<form >
<div id ="b1">
<input type="button" name="b1" title="b1" value="Butt">
</div>
</form>
and you are adding a form inside div "b1"...so form inside form ???? 并且您在div“ b1”内添加了一个表格...因此在表格内添加了表格? change it to
更改为
<div id ="b1">
<form >
<input type="button" name="b1" title="b1" value="Butt">
</form>
</div>
and it should work. 它应该工作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.