Bart Wegrzyn
Bart Wegrzyn

Reputation: 2312

How to have browser open a file from a custom protocol?

I currently have a url that looks like this: protocol://folder/file.js

I can open this same file from my local disk using a url like file://C:\folder\file.js

When the application is run inside its own provided environment, this protocol is available and it loads the file just fine from my local disk.

I'd like to also be able to access these files for times when I run this application inside a regular browser like firefox or chrome.

I've managed to register this protocol on my windows machine and forward the url to a custom c# program that can then open the proper file in browser again. However, it opens the file in a new tab and doesn't seem to work properly when attempting to open the file from a tag on the page.

Is there an easy way to get firefox (or any other browser) to open a file from a custom protocol directly in the tab that requested it?

Upvotes: 3

Views: 1332

Answers (1)

Icemanind
Icemanind

Reputation: 48686

To do this in FireFox, you must implement a XPCOM object. There are instructions on how to do this in C++. For C#, you follow the same instructions, but use GeckoFX to get wrappers for .NET.

Upvotes: 3

Related Questions