How to fix onclick in Phonegap/Android especially in lower versions of Android?

自闭症网瘾萝莉.ら 提交于 2019-12-12 10:27:10

问题


My onclick functionality works in Android devices versions 4, but not in lower versions.

I am facing a similar problem with the CSS position:fixed that did not work in Android devices with lower versions. The alternative I took up was iscroll, but I have yet to fix it up.

I am working in Phonegap/Android using Cordova 2.1.0 and Android 2.2.

My SQLITE plugin is compatible with Cordova 2.1.0.

HTML

<div id="wrapper">
  <div id="scroller">
    <ul>
      <div id="header " class="header ">
        <div id="header_title" class="header_title"> </div>
        <div id="abc" class="abc"><img src="img/home.png" onClick="javascript:abc();"/></div>
      </div>
    </ul>

And another way of calling a page in Javascript is the following:

if(value_in_db==0) {
  document.getElementById("xyz").innerHTML = '<img src="img/inactive.png" />'
} else {
  document.getElementById("xyz").innerHTML = '<img src="img/active.png" onclick="xyz()"/> '
}

In the Function

function xyz(){
   window.location.href="index.html";
}

Images are positioned perfectly. But when I click, it does not call and very seldon it calls.

Note:

All the functionalities work in the higher versions except the devices with lower versions of Android say version 2.2.1.

Please do guide me! How can i fix this?


回答1:


Could you try to handle your click with the addEventListener function?



来源:https://stackoverflow.com/questions/17038857/how-to-fix-onclick-in-phonegap-android-especially-in-lower-versions-of-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!