V
V
vfoken2021-01-06 13:55:32
iPhone
vfoken, 2021-01-06 13:55:32

How to open html document on iphone from "files" folder using chrome or safari?

There is an html document that contains a default doctype and code with a JS script in the body tag to generate random expressions, below is a shortened version:

spoiler

<body>
    <p id="text"></p>
    <input id="generate" type="button" value="Сгенерировать" />

    <script>
      function init() {
        var text = function makePhrases() {
          var words1 = ["Товарищи,", "С другой стороны", "..."];
          var words2 = ["реализация намеченных плановых заданий", "есть сроки", "..."];

          var rand1 = Math.floor(Math.random() * words1.length);
          var rand2 = Math.floor(Math.random() * words2.length);
          var phrase =
            words1[rand1] +
            " " +
            words2[rand2] +
            "!";
          return phrase;
        };

        document.getElementById("generate").onclick = function () {
          document.getElementById("text").innerHTML = text();
        };
      }
      window.onload = init;
    </script>
  </body>



There are no problems with opening this html file in desktop browsers, the phrase generator works as it should, but when opened with iphone, only the "Generate" button is displayed. I opened the html document from the "Files" folder, respectively, the opening of the document itself was carried out by the "Files" application.
spoiler

5ff591cbcca75355776739.jpeg

All that happened when you clicked on the button was to hide the application menu header:
spoiler

5ff5917a719c6677945551.jpeg
5ff59186b19f9462089627.jpeg

When I try to open a document with chrome browser I get the following error:
spoiler

5ff591b7eab41240049319.jpeg

I tried to find a solution in Google, someone writes that I need to replace .onclick with .onpointer in the code, I tried to work with this value - the problem is not solved.
Question:
Is it possible to make iphone open html document directly in chrome or safari without downloading additional apps to view the code? How to do it?
There are certain conditions:
I want to send such an html document to my mother, for example, in a telegram, and so that she simply clicks on the received document and it opens and works, whether in chome or safari, everything should be as simple as possible, since my mother does not understand computers, not on phones.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question