P
P
Podavan12021-11-17 10:33:21
JavaScript
Podavan1, 2021-11-17 10:33:21

Why doesn't Click work in iOS browsers?

Good afternoon, I can’t solve the problem with a click in iOS browsers. The principle of operation is as follows, there is a table and the user clicking on the column copies all the column data to the clipboard, everything works fine on the web, on android, in ios 0 reaction.
The field contains cursor: pointer, adding an onclick="" event did not help.

var copy = document.querySelectorAll(".links");

     for (const copied of copy)
     {
      copied.onclick = function()
      {
        document.execCommand("copy");
      };
      copied.addEventListener("copy", function(event)
      {
        const target = event.target;
        const tag = target.tagName.toLowerCase();
        if(tag === "td")
        {
          event.preventDefault();
          if (event.clipboardData)
          {
            event.clipboardData.setData("text/plain", copied.textContent);
            console.log(event.clipboardData.getData("text"));
            $('.info').html('СКОПИРОВАНО');
          };
       };
      });
     };

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