Contents

# 相對和絕對連結

包含超連結時，必須考量兩個因素：儲存時設定為相對或絕對，以及檔案是否存在。

- Choose LibreOffice - Preferences Tools - Options - Load/Save - General and specify in the Save URLs relative to field if LibreOffice creates relative or absolute hyperlinks. Relative linking is only possible when the document you are working on and the link destination are on the same drive.

- You should create the same directory structure on your hard disk as that which exists in the web space hosted by your Internet provider. Call the root directory for the homepage on your hard disk "homepage", for example. The start file is then "index.html", the full path being "C:\homepage\index.html" (assuming Windows operating system). The URL on your Internet provider's server might then be as follows: "http://www.myprovider.com/mypage/index.html". With relative addressing, you indicate the link relative to the location of the output document. For example, if you placed all the graphics for your homepage in a subfolder called "C:\homepage\images", you would need to give the following path to access the graphic "picture.gif": "images\picture.gif". This is the relative path, starting from the location of the file "index.html". On the provider's server, you would place the picture in the folder "mypage/images". When you transfer the document "index.html" to the provider's server through the File - Save As dialog, and if you have marked the option Copy local images to Internet under LibreOffice - Preferences Tools - Options - Load/Save - HTML Compatibility, LibreOffice will automatically copy the graphic to the correct directory on the server.

- An absolute path such as "C:\homepage\graphics\picture.gif" would no longer function on the provider server. Neither a server nor the computer of a reader needs to have a C hard drive: operating systems such as Unix or macOS do not recognize drive letters, and even if the folder homepage\graphics existed, your picture would not be available. It is better to use relative addressing for file links.

- 與另一個網頁 (例如「www.example.com」或「www.myprovider.com/mypage/index.html」) 的連結就是絕對連結。

- LibreOffice 也依連結中參照的檔案是否存在及其所在的位置而有不同的反應。LibreOffice 檢查每個新連結並自動指定目標和協定。其結果可在儲存來原始文件後產生的 HTML 代碼中看到。

- 可利用下列排序規則：相對定址 (「grafik/bild.gif」) 只有當兩個檔案位於同一個磁碟機上時才有可能。。如果這兩個檔案位於不同的磁碟機上但是於本端檔案系統中，則適用具有「file:」協定 (「file:///data1/xyz/bild.gif」) 的絕對定址。如果這兩個檔案位於不同的伺服器上，或是目前還沒有連結目標，則適用具有「http:」協定 (「http://data2/abc/bild.gif」) 的絕對定址。

- 確保把用於首頁的所有檔案與首頁的啟動檔案放在同一磁碟機上。這樣，LibreOffice 就可以設定協定和目標，以使伺服器上的參照總能保持正確。

滑鼠置於超連結上時，由於 LibreOffice 內部使用的是絕對路徑名稱，提示說明將顯示出絕對參照。只有將 HTML 檔案以「文字」載入或以文字編輯器開啟，才會在檢視 HTML 匯出結果時，看到完整的路徑和位址。

相關主題

編輯超連結

Please support us!