Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8492319
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T22:41:03+00:00 2026-06-10T22:41:03+00:00

I want to create iPhone app using phonegap Cordova 2.0. Now i wrote Javascript

  • 0

I want to create iPhone app using phonegap Cordova 2.0. Now i wrote Javascript external and HTML code. Then i have put the JavaScript code into the HTML5 file. Now i want to run the HTML file on the web browser. When i run the HTML in the Browser the Javascript is not working. The browser shows whatever in the HTML . So could you please help me to run the HTML5 file with JavaScript on the browser and in XCode Phonegap.

This below coding is JavaScript coding.

    

var bodyLoaded = function()
 {
    document.addEventListener("deviceready", onDeviceReady, false);
 }

    // Cordova is ready
    //
    function onDeviceReady() {
        var options = new ContactFindOptions();
        options.filter="";
        filter = ["displayName","organizations"];
        navigator.contacts.find(filter, onSuccess, onError, options);
    }

    // onSuccess: Get a snapshot of the current contacts
    //
    function onSuccess(contacts) {
        for (var i=0; i<contacts.length; i++) {
            for (var j=0; j<contacts[i].organizations.length; j++) {
                alert("Pref: " + contacts[i].organizations[j].pref + "\n" +
                        "Type: " + contacts[i].organizations[j].type + "\n" +
                        "Name: " + contacts[i].organizations[j].name + "\n" + 
                        "Department: "  + contacts[i].organizations[j].department + "\n" + 
                        "Title: "  + contacts[i].organizations[j].title);
            }
        }
    };

    // onError: Failed to get the contacts
    //
    function onError(contactError) {
        alert('onError!');
    }

Below coding is located in my HTML5

 <!DOCTYPE html>
<html>
  <head>
 <meta charset="utf-8" /> 

    <title>Contact Example</title>
    <script type="text/javascript" charset="utf-8" src="Contectscript.js"></script>
   
  </head>
  <body>
    <body onload='alert(1);'>
    <body onload='bodyLoaded();'>
    <h1>Example</h1>
    <p>Find Contacts</p>
  </body>
</html>

Thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T22:41:05+00:00Added an answer on June 10, 2026 at 10:41 pm

    Ok, so you are developing a PhoneGap application.

    In PhoneGap there is a special event called “deviceready” which fires when PhoneGap is fully loaded.

    It is very important that you don’t call any PhoneGap functions before this event fires. It’s possible that the functions are not loaded yet.

    Your problems are:

    1. You are trying to test the javascript in your browser. PhoneGap provides services from your phone to your app. Since you are running it from the web browser there is no phone to provide the services. You cannot simply run your application in the web browser.

    2. You do not have phonegap.js referenced. PhoneGap has a javascript part that must be loaded for your application to work. You should have a line like <script type="text/javascript" charset="utf-8" src="phonegap.js"></script> before your own script (of course the filename can differ depending on the phonegap version you are using, it can be called cordova.js).

    3. Your html contains silly things. There are 3 opening body tag. There should be only 1. You need a HTML like this:

      <!DOCTYPE html>
      <html>
        <head>
        <meta charset="utf-8" /> 
          <title>Contact Example</title>
          <script type="text/javascript" charset="utf-8" src="phonegap.js"></script>
          <script type="text/javascript" charset="utf-8" src="Contectscript.js"></script>
        </head>
        <body onload="bodyLoaded();">
          <h1>Example</h1>
          <p>Find Contacts</p>
        </body>
      </html>
      

    How to solve these problems?

    1. Develop in XCode. There is an emulator built in. It also does the plumbing for you. No need for your external web browser. In your question you already said something about XCode, so this might be a good option. Read this article about setting up and running the project there: http://www.adobe.com/devnet/html5/articles/getting-started-with-phonegap-in-xcode-for-ios.html

    2. Use the Ripple Emulator. It is an emulator designed for emulating phones in the google chrome browser. It can make your application believe that it is running inside your phone as a PhoneGap app and there is all the features of your phone available like accelerometer, gps, etc. It also emulates the deviceready event for you. 🙂

    It’s in like every framework it is an extremely good idea to study the Documentation. There is a very good getting started guide and you can find anwers to your every question about PhoneGap.

    Please read and study the links I have provided for you. It will help you understanding what you are trying to do.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using FMDB for my iPhone App database and i want to create the
I create my first iphone app now i want submit this on appstore so
I want to try to create an iPhone app using PHP and I do
I am currently developing an iPhone app using Apache Cordova (phonegap) and xcode to
I used Phonegap to create a simple webpage as an iPhone app. I'm using
I'm trying to create an iPhone app using xcode, and I want to know
I want to create a iOS app using phonegap. My issue is that ./create
I want to create an iPhone app which makes calls to a web service.
I want to create an Event Calendar for my iPhone App. In a first
I want to create an iPhone/iPad applications using Corona SDK. But they should be

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.