I have a pdf file in a GitHub repo and an anchor tag that points to it (<a href="https://github..../file.pdf>link</a>
) and when I click it, i download the file automatically.
How to make it open the PDF in a new tab, before downloading it (to the file system, just downloading it within the browser)?
I've tried adding target="_tab"
and target="_blank"
to the anchor, but all got me the same results?
Is it achieable using just HTML, or I need to use an external JavaScript library?
You shouldn't need to add
target="..."
whatsoever. I guess you're pointing to the wrong URL. GitHub provides access to the raw file through this URL pattern:Note the
raw
part in the URL. Check if you got your URL right. A functional example:You can test it clicking this link. A dialog will open asking you to specify where to download it.