title: How to implement onclick in javascript and html for devices with lower versions of android?
body: <p>I am working on a project which works perfectly in devices with higher version-I have checked it in 4.1.2 version.</p>
  
  <p>The problem is that it is not working in devices with android version 2.2.1 and 2.3.5.</p>
  
  <p>I have six images to which I have added functionalities. The functionality for 2 images is to call a different HTML page with the id value. The functionality for the other four images is also the same,BUT the images will display based on the database value.</p>
  
  <p><strong>The functionality for 2 images is to call a different HTML page with the id value.</strong></p>
  
  <p>This is how I have coded..</p>
  
  <pre><code>&lt;div id="header " class="header "&gt;
       &lt;div id="header_title" class="header_title"&gt; &lt;/div&gt;
       &lt;div id="abc" class="abc"&gt;&lt;img src="img/abc.png" onClick="abc()"/&gt;&lt;/div&gt;
  -----so -on
  </code></pre>
  
  <p>I have declared the abc function as </p>
  
  <pre><code>function abc(){
     window.location.href="index.html";
  }
  </code></pre>
  
  <p><strong>The functionality for the other four images is also the same,BUT the images will display based on the database value.</strong></p>
  
  <pre><code>if(value_in_db==0) {
    document.getElementById("xyz").innerHTML = '&lt;img src="img/inactive.png" /&gt;'
  } else {
    document.getElementById("xyz").innerHTML = '&lt;img src="img/active.png" onclick="xyz()"/&gt; '
  }
  </code></pre>
  
  <p>I have declared the xyz function as </p>
  
  <pre><code>function xyz(){
     window.location.href="basic.html";
  }
  </code></pre>
  
  <p><strong>Problem Facing:</strong></p>
  
  <p>The onclick functionality functions once in a while in android version 2.2.1 and 2.3.5.when keep on trying to click suddenly the function is called. I have tried fixing this error for almost 2 days.</p>
  
  <p>I had faced a similar problem with the CSS position:fixed. This was not supported in the lower versions of android.I was suggested with a solution <a href="https://stackoverflow.com/questions/16957930/how-to-fix-this-sticky-footer-for-android-devices-in-phone-gap">here</a>. </p>
  
  <p><strong>I have tried with this <a href="https://developer.mozilla.org/en-US/docs/Web/API/EventTarget.addEventListener" rel="nofollow noreferrer">addEventListener function</a> it did not work for me.</strong></p>
  
  <p>I hope I get a solution for this problem to.</p>
  
  <p>Please help me to fix this and guide me!</p>
  
  <p><strong>EDIT :1 touchevent and deviceready</strong></p>
  
  <pre><code>document.addEventListener("deviceready", onDeviceReady, false);
  document.addEventListener( "touchstart", function(e){ onStart(e); }, false );
  function onStart ( touchEvent ) 
  {
     if( navigator.userAgent.match(/Android/i) ) 
     {
          touchEvent.preventDefault();
     }
  }
  </code></pre>
  
  <p>This works in the higher end version but not in the lower end version. I know its baseless to mention 2 <code>document.addEventListener</code>..as it worked in the higher versions.i continued it.</p>