在phonegap中为android调用onload函数的最佳方法(The best way to call onload function for android in phonegap)

编程入门 行业动态 更新时间:2024-10-27 14:33:42
在phonegap中为android调用onload函数的最佳方法(The best way to call onload function for android in phonegap)

当应用程序在设备上运行时,如何调用Onload函数? 在浏览器这一行......运行良好,但是当我在Android设备上运行我的应用程序onLoad函数没有调用时,我可以做onload调用吗?

我试图在"<body onload="onLoad">... </body>"代码中的标签中添加此代码:

<head> // .... <script> document.addEventListener('deviceready', onLoad); </script> <script type="text/javascript" src="js/help.js"></script> <script type="text/javascript" src="cordova.js"></script> </head> <body> </body>

help.js:

function onLoad() { window.alert("onLoad"); }

onLoad-是我在help.js文件中写的函数,我在script标签中添加了这个文件。 在我的Android设备上没有任何警报没有显示。

How can I call to Onload function when the app is run on device? On browser this line ... working well, but when I run my app on android device the onLoad function not calling, whan can I do to make the onload call?

I have tried to add this code in the tag inside of the "<body onload="onLoad">... </body>" code :

<head> // .... <script> document.addEventListener('deviceready', onLoad); </script> <script type="text/javascript" src="js/help.js"></script> <script type="text/javascript" src="cordova.js"></script> </head> <body> </body>

help.js:

function onLoad() { window.alert("onLoad"); }

onLoad- is the function that I write in my help.js file, and I add this file inside script tag. On my android device nothing the alert not show.

最满意答案

window.alert在浏览器中工作,而不是在android中。

你应该使用这里解释的notification.alert

window.alert works in browser and not in android.

you should use notification.alert as explained here

更多推荐

本文发布于:2023-08-07 16:06:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1464915.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:中为   函数   方法   android   phonegap

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!