Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

115
Vistas
How to ENABLE context menu when mobile user long-taps an image in HTML?

My webpage needs to allow mobile users to long-tap HTML image elements to save them to their gallery, like how you can when browsing Google Images on any mobile web browser.

When I create an HTML img element, long-tapping doesn't seem to open the context menu or do anything on Android (Chrome) or iOS (Safari). Even when I set the img element's style to -webkit-user-select: none; (to prevent user from highlighting the image) it doesn't seem to work. I tried reverse-engineering the way Google Images does it, but I can't figure it out.

I would just allow the user to download the image via an anchor element, but this seems to save the photo to the phone's file system, meaning that on iPhone, it won't appear in the user's Photos app (not very user-friendly).

<a download="myImage.png" href="data:image/png;base64,[base64-data-here]">Click me</a>
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

I found the problem. Long-tapping an html img element works as intended. The problem is that I was accidentally using a canvas element instead of an image element. This is how I converted my canvas element into an image element:

var canvas_data = canvas.toDataURL();
var img_element = document.createElement("img")
img_element.src = canvas_data;
document.body.appendChild(img_element);
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda