Uploaded image for project: 'Apache Cordova'
  1. Apache Cordova
  2. CB-8275

Issue updating index.html at runtime‏

    XMLWordPrintableJSON

Details

    Description

      We'd like to report some issues we are facing developing a Cordova app with Visual Studio Community 2013 adding new code lines in index.html file at runtime in Windows Phone 8.1. It seems that only HTML tags are correctly read and executed, instead JS (included in a <script> tag or directly in the element tag e.g. using onclick event) is not executed. We ran the same project on both the Android emulator and physical device and it worked perfectly. Does anybody know wether it's a compatibility issue or something else? Thank you for your attention and help.

      The code is:

      INDEX.HTML:

      <!DOCTYPE html>

      <html>

      <head>

      <meta charset="utf-8" />

      <title>Tester</title>

      <link href="css/index.css" rel="stylesheet" />

      </head>

      <body>

      <input type="button" id="test" value="Prova x Emulatore wp" />

      <!-- Cordova reference, this is added to your app when it's built. -->

      <script src="cordova.js"></script>

      <script src="scripts/platformOverrides.js"></script>

      <script src="scripts/jquery-2.1.1.min.js"></script>

      <script id="last_script" src="scripts/index.js"></script>

      </body>

      </html>

      INDEX.JS:

      (function () {

      "use strict";

      document.addEventListener( 'deviceready', onDeviceReady.bind( this ), false );

      var logOb;

      function onDeviceReady() {

      navigator.notification.alert('ciao');

      // Handle the Cordova pause and resume events

      document.addEventListener( 'pause', onPause.bind( this ), false );

      document.addEventListener('resume', onResume.bind(this), false);

      document.getElementById('test').addEventListener('click', function () {

      var el1 = '<input type="button" id="Prova" value="Ciao"/>',

      el2 = '<script type="text/javascript">document.getElementById(\'Prova\').addEventListener(\'click\', function()

      {navigator.notification.alert(\'Ciao sono il bottone\')}

      , false);</script>';

      $('#test').after(el1);

      $('#last_script').after(el2);

      }, false);

      // TODO: Cordova has been loaded. Perform any initialization that requires Cordova here.

      };
      function onResume() { };
      function onPause() { };

      } )();

      The TrialCode Team.

      Attachments

        Activity

          People

            purplecabbage Jesse MacFadyen
            francin98 Francesco Negri
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: