views:

39

answers:

2

Hello all,

I'm trying to open a help file from within my java application. I am able to do so using the line:

Runtime.getRuntime().exec(new String[] {strPath, strUrl} );

where strPath is the path to IEXPLORE.EXE and strURL is my help file path. However, when I pass a help file with an internal link that contains a space (such as "c:...\helpfile.htm#some section") the page will open in IE, but won't jump to the appropriate section. If I replace the space with "%20", the same thing occurs.

Using the command line in XP, an even stranger thing happens. When I run:

c:\> path\to\iexplore.exe "path\to\helpfile.htm#some section"

I get the same behavior as above, but if I type:

c:\> path\to\iexplore.exe "path\to\helpfile.htm#some%20section"

IE will boot up, but it won't open the file at all, and I get directed to my homepage.

Putting the help file path with a space in it into the address bar of IE successfully directs me to the correct section. Likewise, it seems as though Firefox does not suffer from these shortcomings.

I don't believe I can do much to change the layout of the htm files, or the names of the internal links. Has anyone encountered this issue and are there any suggestions on how to overcome it? Thank you!

A: 

Use the Desktop class, like this:

Desktop.getDesktop().browse(new Uri(path));

Remember that some people (myself included) use Firefox instead of IE.

SLaks
This will launch FF instead of IE if that is the default browser, but it seems to completely ignore the fragment "#some%20section" at the end of the URI. How can I get the browser to go to the full path, instead of just the htm file?
Daven Amin
A: 

Have you tried using a file url?

\path\to\iexplore.exe file:///path/to/your/helpfile.html#some%20section
jeffamaphone
Tried it, it is still a no-go. The html file will appear in IE, and the address in the address bar is correct, but it does not go to the specified section, and if I hit the "go" button, it still will not go to the correct section. The only way to have it navigate correctly is to replace the "%20" of "some%20section" (which appears in the address bar regardless of whether I use "#some section" or "#some%20section" at the command line) with an actual space.
Daven Amin
What version of IE are you using? I am starting to vaguely recall navigation to anchors from the command line being broken in IE7 (known bug)...
jeffamaphone