开发者

issue opening htm files with internal link from command line

开发者 https://www.devze.com 2022-12-11 15:17 出处:网络
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} );

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 th开发者_开发技巧at 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!


Use the Desktop class, like this:

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

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


Have you tried using a file url?

\path\to\iexplore.exe file:///path/to/your/helpfile.html#some%20section
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号