LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   Open HTML file in default browser through C++ (https://www.linuxquestions.org/questions/linux-general-1/open-html-file-in-default-browser-through-c-368164/)

Last Attacker 09-29-2005 11:59 AM

Open HTML file in default browser through C++
 
Hi, I was just wondering if it is possible in Linux to perform a command where you specify an HTML file and Linux automatically opens it in the default Web Browser. I know more or less how to do it in Windows (as our project should run in Windows & Linux), but I need to know if I can do it in Linux.
Its for Help files.

Thanks :)

Komakino 09-29-2005 12:47 PM

There is no 'default web browser'...this is linux, choice is the order of the day! :D You'll have to specify the command to open the browser..possibly trying several until one works.

Last Attacker 09-29-2005 01:26 PM

No I mean Linux detects what the user's Browser of choice is like in Windows and when you open the HTML file, Linux opens that Browser.
Also, if the above method can't work, can anyone please give me some tips on alternatives of how to accomplish this?
Thanks

Last Attacker 09-29-2005 02:05 PM

Nevermind, I've found a html help viewer in wxWidgets (the framework I'm using).
So to display help files won't be a prob. But thanks anyway. Although it would be nice to know how to do it.

LinuxLala 09-30-2005 01:47 AM

I am a little confused by your post. Do you wish to open a html file or do you wish to view the Compiled Help file (.chm) in linux. .chm is the format used by windows for the help files.

You can use xchm to read .chm files in linux
http://xchm.sourceforge.net/

Last Attacker 09-30-2005 05:42 AM

No, I want to open an HTML file and Linux should open the user-defined WebBrowser.
Its mainly for help files. I don't want to open chm files. I'm just wondering if one can call a function in Linux that can do this in C++.

Komakino 09-30-2005 10:04 AM

Quote:

Originally posted by Last Attacker
No I mean Linux detects what the user's Browser of choice is like in Windows and when you open the HTML file, Linux opens that Browser.
Also, if the above method can't work, can anyone please give me some tips on alternatives of how to accomplish this?
Thanks

No, that's exactly what I mean, THERE IS NO DEFAULT browser because there is no default window environment. KDE's way of selecting the 'default' browser is different to gnome's way of doing it, is different to fluxbox's way...etc...hence it isn't possible to detect the user's 'default' browser because the method would be different if the user uses gnome to if they use kde or xfce or....

Last Attacker 09-30-2005 10:39 AM

Ok, but lets say that I'm in KDE, will it open up in conquerer or if in Gnome, in whatever browser gnome uses.
Thats actually what I meant, sorry.
But ok, if its not possible, do you have an idea of how it can be done?

Komakino 10-01-2005 06:27 AM

Quote:

Originally posted by Last Attacker
Ok, but lets say that I'm in KDE, will it open up in conquerer or if in Gnome, in whatever browser gnome uses.
Thats actually what I meant, sorry.
But ok, if its not possible, do you have an idea of how it can be done?

But that's it...you can't just say "open default browser" you'd have to first call some gnome or kde function to open the default browser, probably using some function from either the kde or gnome library.

AdaHacker 10-01-2005 08:08 PM

Quote:

Originally posted by Komakino
But that's it...you can't just say "open default browser" you'd have to first call some gnome or kde function to open the default browser, probably using some function from either the kde or gnome library.
Isn't that saying the same thing?

At any rate, in KDE can just say "open this file in the default application." You can do it from the command line like so:
Code:

kfmclient exec /path/to/file
This will basically run the file as if you had double-clicked on it in Konqueror, opening it in the default handler for its MIME type. Not exactly the same as the "default web browser" concept from Windows, but close enough.

froidnoid 10-20-2005 12:32 PM

Quote:

Originally posted by AdaHacker
Isn't that saying the same thing?

At any rate, in KDE can just say "open this file in the default application." You can do it from the command line like so:
Code:

kfmclient exec /path/to/file
This will basically run the file as if you had double-clicked on it in Konqueror, opening it in the default handler for its MIME type. Not exactly the same as the "default web browser" concept from Windows, but close enough.

Does anybody know how to do this with Gnome (or any other UI framework)?
I got the KDE one to work, but I need to be able to find a way to do this on more distributions then just the ones that use KDE.

Thanks for any hints


All times are GMT -5. The time now is 07:26 AM.