Timer shows military time only on cell phone

Okay, here are the instructions again.

Please let me know at what point you have trouble with getting the fetch.umd.js from the releases page.

ok, have downloaded fetch.umd.js file. and using this

<script src="fetch.umd.js"></script>

Shows blank page

Yes, it doesn’t do anything on the screen.

When the browser already knows how to do fetch, it does nothing. When the browser doesn’t know how to do fetch, it tells the browser how to do fetch.

That script just needs to occur in the HTML page before the script that uses fetch.

1 Like

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <title>Document</title>


<script src="fetch.umd.js"></script>

  </head>
  <body>
    <p id="demo"></p>

    <script>
      function myTimer(d) {
        d.setSeconds(d.getSeconds() + 1);
        demo.innerHTML = d.toLocaleTimeString([], { hour12: true });
      }

      const demo = document.getElementById("demo");

      fetch('../DigitalTimerTest.asp')
        .then(res => res.text())
        .then((res) => {
          const [year, month, day, hour, min, sec] = res.split(',');
          const d = new Date(year, month, day, hour, min, sec);
          setInterval(() => { myTimer(d) }, 1000);
        });
    </script>

    
  </body>
</html>

This is my code with fetch.umd.js in the folder.

It still fails?

yes , just a blank screen

Tomorrow I’ll set up my own asp server to try and figure out where theory departed from practice.

1 Like

thank you, just let me know if I can assist

Does that fetch file live in the same folder as your HTML page?

How do you even create a local development server that can run asp files? Such mysteries may have to wait.

Yes it does.

I have one that I use but it’s a little difficult to set up. I mostly use a live development and upload files. Easier because the local asp consumes to much memory especially if you are using sql with it.

Whatever this is worth, I tried test.html page on my local and it is blank in FF and Chrome but with IE11 is gives me this error:

image

That line would be this:

 exports.DOMException.prototype = Object.create(Error.prototype);

Also to note, I will sometimes, but not common, get errors on local, but when going live have no issues. Therefore, not sure if this is relevant.

Here is a polyfill for Object.create. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/create#Polyfill

I will at some stage though need to get to a machine that has Internet Explorer on it.

thank you, wish I could provide you additional helpful information.

I now have my hands on Internet Explorer.

  • The fetch is good for you. Other issues need to be fixed now.
  • The scripting code uses const which Internet Explorer doesn’t understand. You need to use var there instead of const.
  • Also, the scripting uses arrow notation which Internet Explorer doesn’t understand either. You need to convert those to standard functions instead.
  • Also, the scripting uses destructuring of arrays which Internet Explorer doesn’t understand either, so other techniques need to be used instead.
  • Also, fetch uses promises which Internet Explorer doesn’t understand, so a polyfill is needed to let Internet Explorer know how to handle promises.

And the timer now works in Internet Exporer.

Which one of these issues do you want to tackle first?

Would it be best to make changes for the entire code and I can then use that code if using IE11 and since the existing code works well on chrome and FF just leave that one along? Your thoughts? Thanks

No, that way leads to disaster for you then have multiple versions to support.

1 Like

Ok, I appreciate and definitely respect your opinion. The changes you mention is not something I totally understand. Please tell me the best way to proceed. I already have fetch.umd.js in folder.

Sure thing. Choose one of the issues that Internet Explorer has, and we’ll take you through what need to be done to resolve it.