1. Are you ready for the Galaxy S20? Here is everything we know so far!

Uncaught Reference Error: javascrip function not defined error, though it is defined.

Discussion in 'Android Development' started by KarthikVPai, Aug 9, 2012.

  1. KarthikVPai

    KarthikVPai Newbie
    Thread Starter

    Guys, I am creating an Android-Phonegap app using Eclipse IDE. I have created an HTML file containbing an image and 2 buttons. I have written the following code inside html file.
    <!DOCTYPE HTML>
    <HTML lang="en">

    <HEAD>
    <meta charset="utf-8"/>
    <script type="text/javascript" charset="utf-8" src="cordova-1.9.0.js"></script>
    <script type="text/javascript" charset="utf-8">
    function onLoad() {
    document.addEventListener("deviceready", onDeviceReady, false);

    }

    // Cordova is loaded and it is now safe to make calls Cordova methods
    //
    function onDeviceReady() {
    // Now safe to use the Cordova API

    Obj.addEventListener('touchstart', function(event) {
    // If there's exactly one finger inside this element
    if (event.targetTouches.length == 1) {

    alert("HI");
    }
    }, false);
    }
    var Obj = document.getElementById('id');

    function zoom()
    {
    alert("hi");
    imgGirl.height+=10;
    imgGirl.width+=10;
    }
    function zoomOut()
    {
    imgGirl.height-=1;
    imgGirl.width-=1;
    }
    </SCRIPT>
    </HEAD>

    <BODY onLoad="onLoad()">Hello

    <img id="imgGirl" SRC="MyGirl.jpg" height="50" width="50"/>

    <button id="btnZoomIn" type="button" onClick="zoom()">ZoomIn</button>
    <button id="btnZoomOut" type="button" onClick="zoomOut()">ZoomOut</button>



    <nav>
    <a href="home.html">Home </a>

    </nav>

    </BODY>
    </HTML>

    When I run my app on Android emulator and click the buttons, I get Uncaught reference error in file. the say, "zoom and zoomOut" is undefined.plz help.its urgent.It does not produce any of the dialog boxes.
     



    1. Download the Forums for Android™ app!


      Download

       
  2. Unforgiven

    Unforgiven ...eschew obfuscation...
    Moderator

    I've moved your thread to the Application Development forum where you will get better help.:)

    It is a good idea to edit your post and enclose the code in [code][/code] to make it more readable for other members.
     
Loading...

Share This Page

Loading...