Why javascript can't work?

I made a deck, the front is:

<script type="text/javascript">
  var mode = 1;
  Update(mode);
</script>

the back is:

{{FrontSide}}
<div id='i-backside'>

the Styling is:

<script type="text/javascript">
  var isFont = 0;
  if (document.getElementById("i-backside"))  { isFont = 0; }

  function Update(mode)  {
     if (isFront) {
       ...
    }
 }
</script>

This deck works very well on windows and iphone, but it can’t work on Andriod.
On Andriod, the Front code can work:

  var mode = 1;
  Update(mode);

but in the Styling, function Update(mode) can work, but the code below has never been executed. Why? Thanks.

  var isFont = 0;
  if (document.getElementById("i-backside"))  { IsFront = 0; }

Here’s a modified version of your code:

<script type="text/javascript">
  window.onload = function() {
    var isFont = 0;
    if (document.getElementById("i-backside")) { 
      isFont = 0; 
      console.log('Element found, isFont set to 0');
    } else {
      console.log('Element not found');
    }

    function Update(mode) {
       if (isFont) {
         // Your code here
         console.log('Update function executed with mode:', mode);
      }
   }
  }

  var mode = 1;
  Update(mode);
</script>

1 Like

Now I move the javascript from Styling into FrontSide. It’s OK!