下面的代码可以在我的电脑上的浏览器中运行,但不能在我用 cordova 构建的混合应用程序中运行。我正在使用 Ratchet 框架。
<script type="text/javascript">
window.onload = function () {
document.getElementById('cy_username').value = localStorage.getItem('cy_username');
document.getElementById('cy_password').value = localStorage.getItem('cy_password');
document.getElementById('settingsForm').addEventListener('submit', onFormSubmit, false);
if (localStorage.getItem('cy_pushNotification') == "true") {
document.getElementById('cy_pushNotification').classList.add('active');
}
if (localStorage.getItem('cy_emailNotification') == "true") {
document.getElementById('cy_emailNotification').classList.add('active');
}
showInfoBox();
}
</script>
最佳答案
window.load仅适用于桌面浏览器,供混合应用程序使用,
document.addEventListener("deviceready", function() {
}, false);
关于javascript - window.onload() 不会在混合应用程序中触发,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35809646/