Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

200
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda