PhoneGap error - “Uncaught ReferenceError: cordova is not defined”

前端 未结 1 1152
北海茫月
北海茫月 2020-12-20 18:27

I\'m trying use the menu button on Android, with the PhoneGap. The problem is that I can\'t use it because appear this error on log:

\"Uncaught ReferenceError: cordo

相关标签:
1条回答
  • 2020-12-20 19:29

    First please check that the path and file name to your cordova.js are correct. Then remove the onLoad event and write the deviceready event hook in the script file as shown below:

    <!DOCTYPE html>
    <html>
      <head>
        <!--<script type="text/javascript" charset="utf-8" src="js/cordova-2.6.0.js"></script>-->
        <!--<script type="text/javascript" charset="utf-8" src="cordova-2.6.0.js"></script>-->
        <!--<script type="text/javascript" charset="utf-8" src="js/cordova.js"></script>-->
        <script type="text/javascript" charset="utf-8" src="cordova.js"></script>
        <script type="text/javascript">
          document.addEventListener("deviceready", function () {
            document.addEventListener("menubutton", function() {
              alert('Menu button pressed.');
            }, true);
          }, false);
        </script>
      </head>
      <body>
        <p>Hello world!</p>
      </body>
    </html>
    
    0 讨论(0)
提交回复
热议问题