Home  >  Q&A  >  body text

javascript - How to deal with errors when doing canvas.toDataUrl() on safari and ios?

First I installed two pictures in a p: the picture in base64 format and the local picture obtained by input type=file

Then use html2canvas to synthesize a canvas

Finally, in order to facilitate the long press to save the image on the phone, I want to convert the canvas synthesized by html2canvas into base64 using toDataUrl and then display it with the img tag.

But! Here comes the problem. I reported this error in Safari, and it cannot be converted to base64 on the phone.
All my pictures are in base64 format, and they are not cross-domain. There is no problem in Chrome . Does anyone know what happened? Please give me the ending

伊谢尔伦伊谢尔伦2590 days ago1192

reply all(1)I'll reply

  • 世界只因有你

    世界只因有你2017-05-31 10:43:03

    canvas = document.querySelector("#canvas")??
    The following is a synthesis function page I wrote recently. It can run well on all devices. I hope it can help you.
    http://lonelymoon.linux2.jiuh...
    Or you can give a project link. You need to see the actual effect and code before you can give a solution. Otherwise, you can only rely on guessing. Try typing document in the console. CreateElement("canvas").toDataURL() See if it can run. If it can run, it means there is no problem with the interface and it is a problem within the code.

    reply
    0
  • Cancelreply