Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

199
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!