A library is a special Dreamweaver file that contains a collection of individual assets or copies of assets you have created for placement in your web pages. These assets in a library are called library items. You can update all the pages that use a library item whenever you change the items contents. You can store all sorts of page elements, such as images, tables, sounds, and Flash files in a library.
Heres an example of how you might use a library item: suppose youre building a large site for a company. The company has a slogan that it wants to appear on every page of the site, but the marketing department is still finalizing the text of the slogan. If you create a library item to contain the slogan and use that library item on every page, then when the marketing department provides the final slogan, you can change the library item and automatically update every page that uses it.
Dreamweaver stores library items in a Library folder within the local root folder for each site. Each site has its own library.
NOTE |
|
If the library item contains links, the links may not work in the new site. Also, images in a library item arent copied to the new site. |
When you use a library item, Dreamweaver doesnt insert the library item in the web page; rather it inserts a link to the library item. That is, Dreamweaver inserts a copy of the HTML source code for that item into the document, and adds an HTML comment containing a reference to the original, external item.
The reference to the external library item makes it possible to update the content on an entire site all at once by changing the library item and then using the update commands in the Modify > Library submenu. Then, if you need to change some text for example, or an image, updating the library item automatically updates the instance of the library in any page in which youve inserted the library item.
When you create a library item that includes an element with a Dreamweaver behavior attached to it, Dreamweaver copies the element and its event handler (the attribute that specifies which event triggers the action, such as onClick
, onLoad
, or onMouseOver
, and which action to call when the event occurs) to the library item file. Dreamweaver does not copy the associated JavaScript functions into the library item. Instead, when you insert the library item into a document, Dreamweaver automatically inserts the appropriate JavaScript functions into the head
section of that document (if they arent already there).
NOTE |
|
If you hand-code JavaScript (that is, if you create it without using Dreamweaver behaviors), you can make it part of a library item if you use the Call JavaScript behavior to execute the code. If you dont use a Dreamweaver behavior to execute the code, the code isnt retained as part of the library item. |
There are special requirements for editing the behaviors in library items (see Editing a behavior in a library item). Library items cannot contain style sheets, because the code for those elements is part of the head
section.