• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

Have browser use extension in link to open app with path from link

 
Rancher
Posts: 3795
35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a java program that creates an html file with these links:

I have a program that the OS will open when I click on a file with the .brd extension.

Is there a way to tell a browser to execute that program with the HREF=   value as its argument?

Right now I have a java program that will read the html file, present it in a similar way as a browser and execute the desired program with the path when a link is clicked.
 
Saloon Keeper
Posts: 12027
257
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You need to register your application as the target for a certain protocol. You can do this with an installer for the application.

Then, if you open a link that uses your custom protocol (norm://CU_4thSuitForcing_5F424C002.brd for example) your browser will run your application.
 
Norm Radder
Rancher
Posts: 3795
35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the response.
Do you have a link to an example of how to register an app as target for a protocol?   This is just for my use.  I do not have an installer for the app.
I assume an entry is made in the Windows registry.  Do you have an example export?
Thanks.
 
Marshal
Posts: 25594
69
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I searched the web using register windows app url -- I thought I would find something definitive but the answers seem to be all over the map.

They do all seem to rely on modifying the Windows registry, so you're on the right track. Some of them suggest that different Windows versions have different registry formats, too. So I can't really recommend any of them.
 
Stephan van Hulst
Saloon Keeper
Posts: 12027
257
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Most of them have the same basic premise though. It looks like you only need to do some extra stuff if you want to run custom urls from Edge, and maybe you need to do something completely different on Firefox. I've always had it work reliably on Internet Explorer and Chrome though.

The very first stack overflow link in Paul's Google search seems just fine. If it doesn't work for you Norm, and you can't figure out what the problem is, let us know what you've tried and what operating system and browser you're using.
 
Stephan van Hulst
Saloon Keeper
Posts: 12027
257
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
By the way, the example URL I gave above is wrong. You likely want to open some file that you have stored remotely. In that case it might look something like this:

If just the file name is enough for your application to know what to do, you don't need to specify the host, and therefore you don't have to use the double slashes:
 
Norm Radder
Rancher
Posts: 3795
35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Two steps forward, one step  back.
I made the registry change and changed the URL's protocol and now clicking on the link starts the program but passes it an argument with an unusable path.  I'd rather not change the program to handle the path so back to the drawing board.


With HTML =  <A HREF="ShowBrd://CU_4thSuitForcing_5F424C002.brd">CU_4thSuitForcing_5F424C002.brd</A>;

The program's response with Firefox: C:\WINDOWS\System32\showbrd:\CU_4thSuitForcing_5F424C002.brd\ contains an incorrect path.  


With HTML =  <A HREF="ShowBrd:CU_4thSuitForcing_5F424C002.brd">CU_4thSuitForcing_5F424C002.brd</A>

The program's response with various browsers:
Firefox: C:\WINDOWS\System32\showbrd:CU_4thSuitForcing_5F424C002.brd was not found.                

Chrome:  C:\Program Files (x86)\Chrome\Application\83.0.41-3\showbrd:CU_4thSuitForcing_5F424C002.brd was nor found.  

Edge:    C:\WINDOWS\system32\showbrd:CU_4thSuitForcing_5F424C002.brd was not found.

Internet Explorer: C:\Users\Norm\Desktop\showbrd:CU_4thSuitForcing_5F424C002.brd was not found.



It looks like I need a filter to strip off the leading part before the :

 
Stephan van Hulst
Saloon Keeper
Posts: 12027
257
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What did you put in your registry?
 
Norm Radder
Rancher
Posts: 3795
35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The registry export:


Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\ShowBrd]
"URL Protocol"=""
@="URL:ShowBrd Protocol"

[HKEY_CLASSES_ROOT\ShowBrd\shell]

[HKEY_CLASSES_ROOT\ShowBrd\shell\open]

[HKEY_CLASSES_ROOT\ShowBrd\shell\open\command]
@="\"D:\\CPlusPlus\\EasyBridge-develop_fm_Github\\Build\\Bin\\Debug\\EasyBridge.exe\"  \"%1\" \"%2\""

 
Saloon Keeper
Posts: 22126
151
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Control over what happens when you click a clink in a web browser or other http client app is determined by its MIME type. MIME stands for Multipurpose Internet Mail Extension, so as far as I know, embedding different types of documents in email pre-dates the invention of the World Wide Web.

Traditionally - and specifically in Unix-type OS's, there was a master file: /etc/mime.h - that mapped file extensions to MIME types. So, for example, ".pdf" maps to "application/pdf" in my /etc/mime.h and ".xls" maps to "application/vnd.ms-excel".

The web client app would then be at liberty to do whatever it wanted to do based on the mime type. In most web browsers, there are default actions for the most common MIME types, but they can be customized (for example, to open a file instead of downloading it) and you can add new types. Note, however, that the default action list could vary between clients, so you might have one setting for Firefox and another for Chrome. Note that Excel doesn't run native on Linux, so application/vnd.ms-excel actually is bound on my system to LibreOffice Calc.

Microsoft further complicated things in that not only do the standard Unix config file names and locations map poorly to Windows, but often Microsoft throws in their own unique 2 cents worth, too. There is no such thing as a Windows Registry on other OS's, excepting the limited and rather horrible equivalent that was defined for Gnome, but Microsoft was very big on the Registry (originally Registration Database) for historical reasons - it was more space efficient until NTFS took over from FAT, though much nastier to locate assets or do selective restores from backups.

So to get the desired action, you first have to consider what client app(s) will be used and how they resolve both MIME types and MIME-directed actions. Whether in config files, the Registry or a combination of the above.
 
sunglasses are a type of coolness prosthetic. Check out the sunglasses on this tiny ad:
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic