Apache Cordova:运行时发布更新索引.html
Apache Cordova: issue updating index.html at runtime
我们想报告我们在开发带有Visual Studio Community 2013的Cordova应用程序时面临的一些问题,在Windows Phone 8.1运行时在index.html文件中添加新的代码行。似乎只有 HTML 标签被正确读取和执行,而不是 JS(包含在标签中或直接包含在元素标签中,例如使用 onclick 事件)没有被执行。我们在Android模拟器和物理设备上运行了相同的项目,并且运行良好。有谁知道这是兼容性问题还是其他问题?感谢您的关注和帮助。
代码为:
索引.HTML:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Tester</title>
<link href="css/index.css" rel="stylesheet" />
</head>
<body>
<input type="button" id="test" value="Prova x Emulatore wp" />
<!-- Cordova reference, this is added to your app when it's built. -->
<script src="cordova.js"></script>
<script src="scripts/platformOverrides.js"></script>
<script src="scripts/jquery-2.1.1.min.js"></script>
<script id="last_script" src="scripts/index.js"></script>
</body>
</html>
索引.JS:
(function () {
"use strict";
document.addEventListener( 'deviceready', onDeviceReady.bind( this ), false );
var logOb;
function onDeviceReady() {
navigator.notification.alert('ciao');
// Handle the Cordova pause and resume events
document.addEventListener( 'pause', onPause.bind( this ), false );
document.addEventListener('resume', onResume.bind(this), false);
document.getElementById('test').addEventListener('click', function () {
var el1 = '<input type="button" id="Prova" value="Ciao"/>',
el2 = '<script type="text/javascript">document.getElementById(''Prova'').addEventListener(''click'', function(){navigator.notification.alert(''Ciao sono il bottone'')}, false);</script>';
$('#test').after(el1);
$('#last_script').after(el2);
}, false);
// TODO: Cordova has been loaded. Perform any initialization that requires Cordova here.
};
function onResume() { };
function onPause() { };
} )();
试用代码团队。
这
看起来像一个JQuery问题,在使用之前它没有完全加载。
我总是检查 DOM 是否已准备好使用
$( document ).ready(......
然后检查设备是否像您一样准备就绪。
相关文章:
- 在索引.html和应用.js [node.js] 之间共享变量
- 动态更新特定HTML元素中的选定文本
- 如何在使用javascript添加新元素后更新本地html文件
- 节点.js socket.io 网络服务器提供索引.html以外的其他文件
- 为什么 “/” 在节点.js中没有提供索引.html
- 同时使用索引.html和索引.php时,从 URL 中隐藏索引.php
- 使用 预测 API 数据更新的 HTML 模板
- 通过电子邮件更新内部 HTML
- 如何观察聚合物元素属性值从索引.html的变化
- 如何更新索引数据库中的数据
- 如何将此功能实现到我的索引.html
- 如何打开另一个文件索引.html,具体取决于屏幕的宽度
- 更新的 HTML 表单无法被 Rails 提交识别
- html存储在javascript变量中,如何在javascript变量中更新该html
- 杂乱的JavaScript标签,如何改进索引.html
- 如何使用 JavaScript 更新/更改 HTML 内容并防止页面刷新
- Apache Cordova:运行时发布更新索引.html
- Gulp Serve:渲染索引.html适用于所有路径
- 如何在 Java 中执行页面上的 Javascript 后访问更新的 HTML 源代码
- 如何重新索引 HTML 元素名称和 ID