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

213
Vistas
How to provide a valid (fully qualified?) URL to a drag & drop uri-list item?

I'm afraid I'm struggling with the basics here.. I want to provide a dataTransfer item with a valid URL to a file located on the same server that delivers the website.

Referencing that URL inside a HTML element like this

img_element.setAttribute("src", "some/relative/url.jpg");

..works for me.

But now I want this URL to be referenced by the dataTransfer of a drag event.

Doing s.th. like this:

event.dataTransfer.setData("text/uri-list", "some/relative/url.jpg");

basically works, but since the drag&drop data might be used by some external application (e.g. a file browser) the URL is missing the origin.

On the other hand providing the full URL in a hardcoded way works for the external application, e.g.

event.dataTransfer.setData("text/uri-list", "https://hardcoded.com/subpath/some/relative/url.jpg");

.. but I don't know how turn the relative URL into an absolute one.

I understand that an <img> element doesn't need to provide the full URL since the browser knows the rest - but how do I make the drag event contain all the data it needs to access the data?

I was expecting some function to exist like toAbsolute() which - inside the browser - turns a relative URL into an absolute one but all I found was references to browser.runtime.getUrl() or chrome.runtime.getUrl() but those seem to apply to web extensions only.

Am I on the totally wrong track here?

about 4 years ago · Juan Pablo Isaza
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