ContactFindOptions is not defined (and probably some others too)

Written by lenny cartier.

Everyone starting to develop on mobile devices with API level frameworks such as Cordova or Phonegap will receive this error message one day. This one could freeze your learning curve for a while. So here is a few steps to get rid of it :

<script type="text/javascript">    function onLoad() {
        document.addEventListener("deviceready", onDeviceReady, false);
    function onDeviceReady() {
        var options = new ContactFindOptions();
        options.filter = "";    
        options.multiple = true;
        var filter = ["displayName", "addresses"];
        navigator.contacts.find(filter, onSuccess, onError, options);
    function onSuccess(contacts) {
        for (var i=0; i<contacts.length; i++) {
    function onError(contactError) {

The execution can be made with a <body onload="onLoad()">