Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
142 views
in Technique[技术] by (71.8m points)

javascript - Where do I find cordova.js?

I'm writing a mobile app with HTML5, Javascript and CSS3. I'm using phonegap.

So if I use something like this.

document.addEventListener("deviceready", onDeviceReady, false);

function onDeviceReady() {
    document.addEventListener("backbutton", onBackKeyDown, false);
}

function onBackKeyDown() {
    alert("test");
}

I get this error:

cordova : You must have cordova.js included in your projects, to be able to trigger events.

I'm using Ripple to emulate a smartphone. And its right. I don't have cordova.js in my project folder, because I don't know where i get it. I have downloaded the newest version 2.9.0 of phonegap and using specially cordova-mobile-spec.

There is no cordova.js just a cordova-incl.js. How do I obtain this file?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

I wasted a lot of time looking for a solution on the question "Where get the cordova.js?".
I am developing a mobile app using html+css+jQuery mobile and i am building it using the phonegap web build service. The version of phonegap i am working on is 3.1.0.

I was trying to find how to use the Phonegap API on my mobile application and how to call the cordova methods (ex notification.alert). The solution to this is to just add the

<script type="text/javascript" charset="utf-8" src="cordova.js"></script>  

inside the head of your index.html document. The Phonegap builder will find and include the correct cordova.js file for each build (Android, Win phone, iOS).

Finally, the ondeviceready event is essential to any application. See the Full Example.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...