Adding Hyperlinks to Documents

One of the program's most powerful features is the ability to insert a link to any file or site, into any of its document. With the document open in edit mode, or in other modes such as delivering a presentation, you can click the link to go to the file or site.

You can insert links not only in HTML documents but in Writer, Calc, Impress, and any other documents where the hyperlink bar is available.

To unlink items, see Unlinking on page 478.

This section covers the following topics:

  • How the Hyperlink Toolbar Icons Work

  • Setting Relative or Absolute URL Save Options

  • Linking to a File, Web Site, FTP Site, or Event

  • Linking to Targets

  • Linking to a New Email or News Document

  • Linking to a New Empty File

How the Hyperlink Toolbar Icons Work

The three different URL fields, and all sorts of Link and Hyperlink icons, make it a little hard to figure out what kinds of links you can do with each of the parts of the work area. Figure 16-1 points out the key differences among the link- related features, for inserting hyperlinked text and buttons (inserting graphics that you can hyperlink is covered later in this section).

Figure 16-1. Getting to know the link tools

graphics/16fig01.jpg

Setting Relative or Absolute URL Save Options

The Save options window contains two fields that control how URLs are saved: relative to the file system or Internet, or absolute. See Absolute and Relative Paths, and Fixing Broken Links on page 138 to specify how you want URLs saved.

Note

Tool tips always display the absolute path, even if only the relative path is saved. In HTML files, you can choose View > HTML Source to see what's really in the link.


Linking to a File, Web Site, FTP Site, or Event

The Hyperlink window lets you create links not only to Web sites and files, but to items such as new email or news documents and scripts. It also lets you set up names for the links, so you can reference those links in scripts. This procedure provides an overview; more advanced features such as linking to a macro are covered in other sections in this and other Web chapters. The window is shown in Figure 16-2; steps follow it.

  1. Open any document.

  2. Position the cursor in the document where you want the link to appear.

  3. Click the Hyperlink Dialog icon.

    graphics/hyperlinkdialog.jpg

  4. On the left side of the window (Figure 16-2), leave Internet selected, or select Document. Enter as many links as you want, then click Close.

Figure 16-2. Adding a hyperlink:

graphics/16fig02.jpg

Note

To change the link later, you can't select it and click the Hyperlink Dialog icon again. You need to select it and choose Edit > Hyperlink.


Linking to Targets

Targets are points within your document that you can specifically link to; for example, you might want to set up a short table of contents at the beginning of the document, and link each line to a particular heading within the document. You can also link to specific objects (these vary depending on the application you're using). This is particularly useful for going to a specific paragraph within a long document.

Linking to a Heading or Object Within a Document

This works with Web, Writer, and Calc documents, but not Impress, Draw, or Image. In Calc you can link to other sheets, and to range names and database ranges.

Note

The heading-linking feature is extremely inconsistent; if you find that clicking on your hyperlink takes you absolutely nowhere, you'll need to do it in the HTML. So don't beat your head against this feature too long. We've covered that in the next procedure, Linking to a Target Within a Document on page 473.


  1. Open the document.

  2. If you're linking to a heading, be sure that one of the styles in heading1 through heading5 is applied. (Choose Format > Stylist.)

  3. Select the text that you want hotlinked, so that users clicking on that text will go to a graphic, table, heading, or other element of a document.

  4. Click the Hyperlink Dialog icon to display the Hyperlink window (Figure 16-3).

    Figure 16-3. Linking to a graphic target or other file target

    graphics/16fig03.jpg

  5. In the region on the left side of the window, select Document.

  6. If the target item is in a different document, click the Open file icon next to the Path field and select the file.

  7. Click the Target in document icon by the Target field to open the navigator, then select the item you want to link to.

  8. Click Apply, then Close. In the Hyperlink window, click Apply and Close also.

Note

To name graphics and tables so you can tell which one to select in Navigator, right-click and choose Graphics or Table. Enter a name in the Graphics or Table tab.


Linking to a Target Within a Document

The Hyperlink window doesn't let you link to any text that doesn't have a heading style in the range Heading 1 through Heading 5 applied to it. It also frequently falls flat when you try to link to headings. We've provided instructions on how to do it the old-fashioned way in HTML. (HTML novices, this is extremely easy.)

Creating the Target, Using HTML
  1. Open the document containing the items you want to be able to jump to, such as headings within a long document, graphics, or other elements. An example is shown in Figure 16-4.

    Figure 16-4. File you want to add targets to

    graphics/16fig04.jpg

  2. Plan what you want name the targets: for example, the headings in Figure 16-4 might be morefun , justneed , progbeg , and remember . Just make sure they're all unique.

  3. Click the Show HTML Source icon on the toolbar (the last tool) or choose View > HTML Source.

  4. Locate the first heading and type the following in front of the heading text:

     <A NAME="target_name"></A 

    For example, the line for the heading "More Fun, Better Learning" might look like this:

     <H2><A NAME="morefun"></A>More Fun, Better Learning</H2> 
  5. Repeat the previous step for all elements in the document that you want to be able to jump to.

  6. Save the file first, then switch off the HTML source, returning to normal view.

Linking to the Target You Created Using HTML
  1. If you want to link from a different document, open it, or just keep the same document open.

  2. Choose View > Source.

  3. Go to the HTML for the text you want to link from . For example, you might have a table of contents at the beginning of the document:

    • More fun, better learning

    • Just what you need

    • For programmers or beginners

    • You'll remember what you learned

    Go to the text for the first bullet:

    [View full width]
     
    [View full width]
    <UL> <LI><P>More fun, better learning</P> <LI><P>Just what you need</P> <LI><P>For programmers or beginners</P> <LI><P>You'll remember what you learned</P> </UL> <P><FONT FACE="Arial, sans-serif"><A NAME="morefun"></A><B>More Fun, Better Learning</B></ graphics/ccc.gif FONT></P>
  4. Add the name of the target as shown in bold in the following example, to everything you want to click on and go to a target.

     <UL>     <LI><P>  <A HREF="morefun">  More fun, better learning  </A>  </P>     <LI><P>  <A HREF="justneed">  Just what you need  </A>  </P>     <LI><P>  <A HREF="progbeg">  For programmers or beginners  </A>  </P>     <LI><P>  <A HREF="remember">  You'll remember what you learned  </A>  </P> </UL> <P><FONT FACE="Arial, sans-serif"><  A NAME="morefun  "></A><B>More Fun, Better Learning</B></FONT></P> 

Linking to a New Email or News Document

The Hyperlink window lets you create links not only to Web sites and files, but to items such as new email or news documents and scripts. It also lets you set up names for the links, so you can reference those links in scripts.

Note

More advanced features such as linking to a macro are covered later.


  1. Open any document.

  2. Position the cursor in the document where you want the link to appear.

  3. Click the Hyperlink Dialog icon.

    graphics/hyperlinkdialog.jpg

  4. In the region on the left, select Mail & News (see Figure 16-5).

    Figure 16-5. Linking to a new email document or news document

    graphics/16fig05.jpg

    Enter as many links as you want, then click Close.

Linking to a New Empty File

This feature opens a new empty file of the type you specify when the hyperlink is clicked.

  1. Open any document.

  2. Position the cursor in the document where you want the link to appear.

  3. Click the Hyperlink Dialog icon.

    graphics/hyperlinkdialog.jpg

  4. In the region on the left, select New Document (Figure 16-6).

    Figure 16-6. Adding a new document link to a document

    graphics/16fig06.jpg

    Enter as many links as you want, then click Close.

    The files are created based on the standard template for the application you select.

Adding Hyperlinks to Graphics

This procedure describes how to add a hyperlink to a graphic you've already inserted.

Note

This works only with graphics added using Insert > Graphic, not pasted graphics.


  1. Select the graphic, then right-click it and choose Graphics.

  2. In the Graphics window, click the Hyperlink tab.

  3. Enter the hyperlink information, as shown in Figure 16-7.

    Figure 16-7. Hyperlinking a graphic

    graphics/16fig07.jpg

Unlinking

To unlink a graphic, just open the Graphics window again (right-click and choose Graphics), then click the Graphics tab, delete the URL and click OK.

To unlink a text or button hyperlink, deleting the URL doesn't work. To unlink any text, button, or graphic, select and choose Format > Default.

Viewing and Editing Links in a Document

To change existing links, or see exactly what the link is, you have several options. You can edit the HTML source code, of course. The rest of the options are covered here.

Using the Hyperlink Window

Just select the item and open the Hyperlink window again (click the Hyperlink Dialog icon) to make changes.

Unlinking a Text Link

Select it and choose Format > Default.

Quickly Changing a Text or Button Link

Select a text or button link in the window, change the URL in the Internet URL field, then click the Hyperlink icon on the hyperlink toolbar or press Enter.

Editing an Individual Text Link

Select a link and choose Edit > Hyperlink.

Curiously, this works only for text links created using the Internet URLs or Hyperlink window, not for button links created using that window, or for any graphics links.



OpenOffice. org 1.0 Resource Kit
OpenOffice.Org 1.0 Resource Kit
ISBN: 0131407457
EAN: 2147483647
Year: 2005
Pages: 407

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net