Into a text cell of my current (previously saved) notebook, I want to place a hyperlink to a particular file target.html
in a particular subdirectory subdir
of the notebook's directory.
I don't see a way to do this directly using the menu item Insert > Hyperlink.
However, if I edit the cell as an expression, I can form the following:
Cell[TextData[{
"Look at this ",
ButtonBox["page", BaseStyle->"Hyperlink",
ButtonData:>{
URL[
StringJoin["file://",
FileNameJoin[{NotebookDirectory[], "subdir/target.html"}]
]
],
None}],"..."
}], "Text"]
(Above, I've hand-formatted the display to correctly display the structure, I hope.)
However, once I convert that expression back into a text cell in the notebook and click the hyperlink, the indicated file does not open in the default browser.
What's wrong and how should it be fixed?
"file://"<>FileNameJoin[{NotebookDirectory[],"subdir/target.html"}]
. But when I click the resulting hyperlink, I get error "The front end failed to execute the command file File:///Users/murray/dir/subdir/target.html", where dir is the notebook's directory. $\endgroup$SystemOpen @ FileNameJoin[...
only? I'm not quite sure where is thisfile://
part from and whether it should work or not. $\endgroup$Hyperlink["test","file:///"<>FileNameJoin[{NotebookDirectory[],"subdir/target.html"}]]
. (And this has nothing to do with the target file being in a subdirectory of the notebook's directory.) The issue is that the expression generates a link with an embedded space. How to fix? $\endgroup$