0 Replies Latest reply: Jan 29, 2013 5:51 AM by 840187 RSS

    JQuery/Javascript not working on Firefox and Chrome

    840187
      Hi guys, I've had this Jquery/Javascript on my page for a long time. This has stopped working. If the user clicks on buttons on the Apex page, nothing happens.
      It works on IE but doesn't work on Firefox and Chrome. It used to work fine.

      Is there anything I can change to make it work on all 3 browsers?

      Firefox error console shows a syntax error at this point in the script:

      $allButtons.click(function(){
      itemChanged = false;
      var toDo = $(this).attr('data-submitval');
      eval(toDo);
      });

      Please can someone help?

      This is the full script:

      <script type="text/javascript">
      //<![CDATA[
      var itemChanged = false;

      $(document).ready(function(){
      var $items = $(':input');
      var $htmlButtons = $(':button[id]');
      var $templateButtons = $(':button[class]');
      var $allButtons = $($htmlButtons).add($templateButtons);

      $items.change(function() {
      itemChanged = true;
      });

      $templateButtons.attr('data-submitval', function(){
      return $(this).attr('onclick').toString().split('\n')[2];
      });

      $htmlButtons.attr('data-submitval', function(){
      return this.id;
      });

      $allButtons.removeAttr('onclick');

      $allButtons.click(function(){
      itemChanged = false;
      var toDo = $(this).attr('data-submitval');
      eval(toDo);
      });

      $('a').click(function(event){
      if ($(this).children('img[id="P&APP_PAGE_ID._DATE_PICKER_IMG"]').length > 0) {
      event.preventDefault();
      eval($(this).attr('href'));
      }
      });
      });

      window.onbeforeunload = function() {
      if (itemChanged) {
      return 'You have made changes to data on this page. If you navigate away from this page without first saving your data, the changes will be lost.';
      }
      };

      //]]>
      </script>


      Thanks

      Sam

      Edited by: sam on 29-Jan-2013 03:50