Is it possible to create a link that opens a local HTML file in the browser?

I am trying to create a link within a card that will open a locally stored HTML notebook in the browser. The file needs to be opened with the “file:///” protocol in order to work properly, so I can’t just store it in “collection.media”.

I have tried adding the following HTML directly to a field (using Ctrl+Shift+X):

<a href="file:///C:/Users/Me/Desktop/file.html">link</a>

This appears as a clickable link when viewing the card, but if I click on it nothing happens. I have no problem getting similar links to work when they use the “https://” protocol. I know that the file path is correct because it works if I copy it directly into the browser. I’ve also tried on a separate Windows 10 machine in case there was some problem with my OS.

Normally I would assume that Anki is not supposed to be able to open files in this way, but I asked the creator of the plugin that I am using and he said that it worked for him on a virtual Windows 10 machine.

Is there any way to get this to work?

I am using Anki 2.1.35 on 64 bit Windows 10.

Interesting. I just tested this on Anki 2.1.22 on Windows 10 64-bit and have the same issue. My default browser is Firefox.

It’s clunky AF, but if you get desperate you could host your pages on a local web server and access them from Anki with “http://localhost/foo/bar.html” etc.

When Anki does not behave as expected sometimes you get debug/diagnostic information by running Anki from the command line which allows you to see some output.

Recent Anki builds have a file that’s named “anki-console” in C:\Program Files\Anki\ which you can run from the cmd window. Maybe google for something like “how to run program from cmd”.

 

When I click a hyperlink that has a file:///as a target on my windows computer in my cmd window I see this line:

JS error :0 Not allowed to load local ressource: file:///C:/Users/.../myfile.html

When you see cards you basically see them in a web browser that’s built into Anki and for security reasons that has no access to your file system (except for your media folder). That’s relevant because you don’t know what’s inside your shared decks you use …

There’s probably a reals solution …

workaround: put the html notebook file into your media folder? make a hardlink to your desktop? I use the software “link shell extensions” on windows or even more secure because you install less software is to type one command into your cmd to create your hardlink.

another workaround might me my Open linked pdf, docx, epub, audio/video, etc. in external Program (which might not work on Macs because I don’t have a Mac where I could test it).

1 Like