onLoad功能phonegap android [英] onLoad function phonegap android

查看:61
本文介绍了onLoad功能phonegap android的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要用onload函数替换哪些代码?

我创建了一个phonegap项目,当我在浏览器中运行它时,它可以正常工作,onload函数可以运行,但是在我的android设备上-没有任何作用.

此问题的原因是什么?

解决方案

您可以像这样在页面的onLoad上调用函数

document.addEventListener('deviceready', function(){ alert("hello") });

别忘了将cordova.js或phonegap.js添加到您的html文件中

已根据评论更新

help.js(另一个js文件)

document.addEventListener('deviceready', LoadPage);

function LoadPage()
{
  window.alert("loadPage");
}

这是一个最简单的JSFiddle演示,只需遵循HTML文件的结构即可运行,而无需添加其他文件

祝一切顺利

Which code I need to replace with onload function?

I create a phonegap project, when I run it on the browser it's work fine, the onload function work, but on my android device - nothing.

What is the cause of this problem?

解决方案

You can call function like this onLoad of page

document.addEventListener('deviceready', function(){ alert("hello") });

Dont forget to add cordova.js or phonegap.js to your html files

Updated As per the comments

help.js(another js file)

document.addEventListener('deviceready', LoadPage);

function LoadPage()
{
  window.alert("loadPage");
}

Here is a Simplest JSFiddle Demo, just follow the structure of Html file and run without adding extra files.

All the best

这篇关于onLoad功能phonegap android的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆