Re: Hyperlinks to htm files
- To: mathgroup@smc.vnet.net
- Subject: [mg12346] Re: Hyperlinks to htm files
- From: paulh@monon.wolfram.com (P.J. Hinton)
- Date: Sun, 10 May 1998 02:04:30 -0400
- Organization: Wolfram Research, Inc.
- References: <6itg57$17n@smc.vnet.net>
In article <6itg57$17n@smc.vnet.net>, "James Wyant" <jcwyant@u.arizona.edu> writes: |> I am trying to use hyperlinks to jump from a Mathematica notebook to htm |> files in the same folder as the notebook. The only way I can get the |> hyperlink to work is to supply it with an absolute address as shown |> below. |> |> Cell[TextData[ButtonBox["Surface Plot", |> ButtonData:>{ |> URL[ "E:/ZernikeNotes/CylindricalPlot3DN1.htm"], None}, |> ButtonStyle->"Hyperlink"]], "Text"] |> |> I have no problem using relative addresses for hyperlinks between two |> Mathematica notebooks, but I am not able to use relative addresses for |> hyperlinks between notebooks and htm files. Does anyone have a |> solution? |> |> Also, is it possible to use hyperlinks in Mathematica notebooks to open |> files in other programs such as PowerPoint? The following discussion is fairly detailed, but I believe that it will shed some light on the behavior that you're observing. Please keep in mind that, unlike a webbrowser, Mathematica has no native mechanism for pairing together MIME types and file extensions with helper applications. Mathematica hyperlinks are represented at ButtonBox[] structures. If you unformat the Hyperlink prototype in a style sheet notebook, you will find that the underlying ButtonFunction looks like: FrontEndExecute[{FrontEnd`NotebookLocate[#2]}]& The NotebookLocate[] function gets its argument from the ButtonData option of the ButtonBox, and it can accept three different types of arguments: 1) A string, which is a cell tag value that is to be searched within the notebook where the ButtonBox resides. Searching begins with at the location of the ButtonBox and proceeds to the first occurrence of the tag. 2) A list of two items. The first item can be a string or FrontEnd`FileName object. The second item is a cell tag value string. The file, if found, will be opened in Mathematica, so it must be a notebook. 3) A list with the first element being a URL[ ] expression which contains a string with anything that could be used as a value for the href attribute in an HTML anchor (A) tag. This includes "http://..." and "mailto:..." or whatever your browser may understand. The second element in the list must be None, since there is no such thing as a cell tag outside of a Mathematica notebook. Your work involves case (3). Basically, Mathematica is passing an unprocessed string to the web browser, and this string must be contain sufficient information for the browser to resolve the string to a valid path. If you supply a path that is relative to the location of a notebook, then the action is doomed to fail because the path that the browser needs is the path relative to the launch directory of the browser, and there is a near 100 percent probability that the notebook's and webbrowser's directory do not coincide. To get Mathematica to have a PowerPoint file opened when you click on a hyperlink, you can use a URL expression (3) and exploit the browser's built-in file extension -> helper app associations. Again, you will have to specify the path to the file in such a way that it will be valid relative to the browser application. You will also need to make sure that your browser is properly configured so that PowerPoint is listed as a helper app for whatever file extension that PowerPoint uses. After this is done, clicking on a hyperlink will send the filename to the browser, which then should determine that PowerPoint should be used as the helper app. -- P.J. Hinton Mathematica Programming Group paulh@wolfram.com Wolfram Research, Inc. http://www.wolfram.com/~paulh/ Disclaimer: Opinions expressed herein are those of the author alone.