简体   繁体   English

在我的Phonegap应用中的onclick事件不起作用

[英]Doesn't work the onclick event in my Phonegap app

my name is Borja and i just started programming with PhoneGap and my first issue is related with the non-existent executing of .js files. 我的名字叫Borja,我刚开始使用PhoneGap编程,而我的第一个问题与不存在执行.js文件有关。 This is my index.html code : 这是我的index.html代码:

<html>
<head>
   <meta charset="utf-8" />
  <meta name="viewport" content="width=device-width, user-scalable=no">
  <link href="css/jquery.mobile-1.4.3.min.css" rel="stylesheet" type="text/css" />
  <link rel="stylesheet" href="css/font-awesome.min.css" />
  <link rel="stylesheet" href="css/jquerymobile.nativedroid.css" />
  <link rel="stylesheet" href="css/jquerymobile.nativedroid.light.css"  id='jQMnDTheme' />
  <link rel="stylesheet" href="css/jquerymobile.nativedroid.color.green.css" id='jQMnDColor' />
  <link rel="stylesheet" href="css/custom.css" />
  <script src="js/jquery-1.9.1.min.js"></script>
  <script type="text/javascript" charset="utf-8" src="js/index.js"></script>    

</head>
<body>

<div data-role="page" data-theme='b'>


    <div data-role="header" data-position="fixed" data-tap-toggle="false" data-theme='b'>
        <a href="index.html" data-ajax="false"><i class='fa fa-bars'></i></a>
        <h1>Ejemplos de Funciones Nativas</h1>
    </div>

    <div data-role="content">   

    <div class='inset'>

     <ul data-role="listview" data-inset="false" data-icon="false" data-divider-theme="b">
        <li data-role="list-divider">Funciones Nativas <span class="ui-li-count">2</span></li>
        <li><a href="#Camara">
            <img src="http://www.alfa-klebstoffe.com/fileadmin/icons/059270-3d-glossy-blue-orb-icon-people-things-camera.png">
            <h2>Camara</h2>
            <p>Prueba de Ejecucion de Camara en dispositivo movil</p>
            <p class="ui-li-aside"><strong>Hacer foto , Guardar Foto</strong></p>
        </a></li>

        <li><a href="#GPS">
          <img src="https://cdn3.iconfinder.com/data/icons/sphericalcons/128/satellite.png">
          <h2>GPS de android</h2>
          <p>Prueba de Ejecucion del GPS del movil</p>
          <p class="ui-li-aside"><strong>Probar GPS</strong></p>
          </a></li>

        <li><a href="#GoogleMaps">
          <img src="https://cdn2.iconfinder.com/data/icons/google-ios-7-app-icons/120/google_maps.png">    
          <h2>Google Maps</h2>
          <p>Pruebas sobre la app de Google Maps de android</p>
          <p class="ui-li-aside"><strong>Geolocalizacion</strong></p>
        </a></li>

        <li><a href="#Conexion">
          <img src="http://static.iconsplace.com/icons/preview/purple/wifi-256.png">
          <h2>Internet</h2>
          <p>Comprobacion conexion Internet del movil</p>
          <p class="ui-li-aside"><strong>WIFI,3G</strong></p>
          </a></li>


    </ul>


    </div>  


    </div>

</div>


<div  id="Camara" data-role="page" data-theme='b'>

    <div data-role="header" data-position="fixed" data-tap-toggle="false" data-theme='b'>
        <a href="index.html" data-ajax="false"><i class='fa fa-bars'></i></a>
        <h1>Distintos Usos de camara</h1>
    </div>

    <div data-role="content">

    <div class='inset'>

       <!-- <a data-role="button" href="" onclick="capturePhoto();">Capturar Foto</a><br>
        <a data-role="button" href="" onclick=" capturePhotoEdit();"> Capturar Foto Editable</a><br>
        <a data-role="button" href="" onclick="getPhoto(pictureSource.PHOTOLIBRARY);">From Photo Library</a><br>
        <a data-role="button" href="" onclick="getPhoto(pictureSource.SAVEDPHOTOLIBRARY);">From PhotoAlbum</a><br>
        <img  id="smallImage" style="display:none;width:60px;height:60px;" src="" /> -->

   <form>
     <button data-role="button" onclick="prueba();return false;" ><i class='lIcon fa fa-refresh'></i>Refrescar Personal</button>
   </form>        
 </div>


  </div>
  </div>
</div>
  <script src="js/jquery.mobile-1.4.3.min.js"></script>

</body>

Like you can see, in the Camara data-role page (the last one) i added a onclick event in the button, with the next code: 如您所见,在Camara数据角色页面(最后一个页面)中,我在按钮中添加了一个onclick事件,并带有下一个代码:

   function prueba(){
    alert("Carlos limpiate los zapatos");

}
- 

When I open the app and I press button, the applicacions returns to the home...so my app can't read the javascripts functions and i dont know what is the reason, so i need help. 当我打开应用程序并按下按钮时,应用程序将返回首页...因此我的应用程序无法读取javascripts函数,我也不知道是什么原因,所以我需要帮助。

Thanks so much, 非常感谢,

Borja Borja

did you to call alert("Carlos limpiate los zapatos"); 您是否致电过快讯(“ Carlos limpiate los zapatos”); directly on the onclick event if it work, may be there is a problem with the js file. 如果可行,则直接在onclick事件上进行操作,可能是js文件有问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM