Open .pdf, .txt, .docx, etc documents from a list of paths

I have a list of document paths listed in Dash. I want to make the document paths clickable so that users can open the documents by clicking the document paths. For instance, if the path is a .docx document, the user’s default .docx program should pop up. Is there a way to do this in Dash?

I tried using dcc.Link with the href parameter as the filepath. I also tried using html.A with the href parameter and target=‘_blank’. Both didn’t work unfortunately. I got the following error:

react-dom@16.v2_9_3m1685119029.14.0.min.js:32 Uncaught DOMException: Failed to execute ‘pushState’ on ‘History’: A history state object with URL ‘file:///C://…’ cannot be created in a document with origin ‘’ and URL ‘http:’.

Not sure if this is the right way to go or if there is a better route. Any help is greatly appreciated!

Hello @williamwirono,

I dont think that you can make it happen by default, it would have to be defaulted on each computer what to do with a downloaded document.

You can allow a download of the object with a dcc.Download, other than that, typically controlling a computer from a browser is a no-no due to viruses/malware/etc. :slight_smile:

@jinnyzor Hmm gotcha. I am a bit reluctant in making it as a download feature since the user has already had those files in their system. I just wanted to open the file in that path. But anyways, thanks for the input! If you think of something as you go, please do reach out!

If the user already has the folder, you can hard code it.

I believe the path for a file is something like:


@jinnyzor I tried this, and it gave me the following error in the Console: ‘Not allowed to load local resource.’ Has this got something to do with the browser’s security settings?

Nevermind, got it to work in Chrome. You will need to install a Chrome Extension called ‘Enable local file links’ to allow links to local files that was disabled by Chrome by default.

1 Like

I believe it is regularly disabled…

I dont know if you could skirt around this with having an onclick function that forces the browser to open a new window at that location.