Learning about the JavaScript File

What You Will Learn

Each time you create a menu, the PluginLab extension creates a JavaScript file holding all of the code that explains to a browser how to handle your menu system. The following tutorial explains how the PluginLab extensions create and maintain a JavaScript file. You will learn how to create the file, load a new file, rename the file, and move the file.

Before You Start

 

1. About the Script File

When you open any of the PluginLab menu extensions, a JavaScript file is automatically created in the Scripts folder below the PluginLab folder in your Dreamweaver site root folder.

We recommend that you accept the default file name and location for the script file. This ensures that Dreamweaver and your browser can locate the file in order to implement the menu functions.

The script is automatically named PLHIM.js. Each time you modify your menus, the script records and saves those changes. If you opened the script file, you would see something similar to the picture below.

When you finish choosing the settings for your menu and add it to your HTML page, a <script> tag is added to the Head area of the page. This tag defines the type of script file, its name, and where it is located. An example is shown below.

Do not edit the script tag in Dreamweaver. When you open the extension's dialog box and make changes, any necessary changes to the script tag are made for you.

An attribute onLoad is also added to the opening <body> tag of the page that tells the browser to open the script file when the page is displayed.

PluginLab menu extensions support placing one of each style of menu on an HTML page. If it is absolutely necessary to have more than two menus, consider using a frame or iframe display for the third menu. Be aware, however, that using frames introduces several problems, such as faulty search engine indexing, bookmaking problems, DHTML not working across frame borders, and so on.

 

2. Using the Script File

Each time you select a PluginLab menu on the Insert menu of Dreamweaver, the extension opens a new script file if none exists for the page or reloads the script file used on that page.

If you move the script file manually, without opening the extension itself and designating a new location in the Save/Load area on the General tab, your menus will not work.

Do not modify the script file directly by opening it in Dreamweaver or another HTML editor.

 

3. Duplicating a Menu Design

If you create a menu design you really like for one site, you can use that same menu design on another site by loading the preferred script file when you first open the PluginLab menu extension from the Insert menu.

When you select the new script file, the path to the script is included. You can change whether the file path should be relative to the site root of your site (as defined in Dreamweaver) or relative to the document that references the script file.

For duplicating a menu design you have to do the following:

1. Click the folder to locate a different script file.

2. Click the name of the script file you want to use and after that click the button.

PluginLab automatically places script files in a folder relative to your site root: /PluginLab/Scripts/

By putting all scripts for a site in one folder, it reduces the complexity of your site structure and makes it easier to reference a script from other folders within the site.

If the .js file is in the same folder as the HTML page, then its path is relative to the document.

To learn more about relative path names, read Understanding Path Names.

 

4. Moving or Renaming a Script File

You may want to rename a script file to match a site name, a client's name, or some other name that makes it more obvious what the menu is used for.You may also want to move a script file from one Dreamweaver site to another.

Always use the PluginLab extension to rename or move a script file.

Rename a script

Before you rename a script file, make a copy of the original file and save it to a new location or change the extension of the original file from .js to .org. To use the original file, change the extension back to .js

  1. Open the PluginLab extension.
  2. On the General tab, in File Name select the current name of the script and type a new name for the script file.
  3. Click OK to save the name change.

If the script is used on multiple pages, you need to update those pages.

Move a script

Always use the PluginLab extension to move a script. If you move a script file manually, you may find your menus do not work correctly.

  1. Open the PluginLab extension.
  2. On the General tab, click the folder next to the Save/Load Script.
  3. In the Select dialog box, browse to the folder on your computer or network where you want the renamed script file to be located.
  4. In File Name type a name for the script file.
  5. In Files of Type, select JavaScript Files (*.js)

Delete a menu

Never remove a menu manually by removing the script tags or the HTML tags for the menu itself.Open the PluginLab extension.

  1. Open the PluginLab extension.
  2. Click Delete.

All of the references to the script and the HTML code are removed.

Changing a Script File

Everything you need to do to create or modify menus can be done using the PluginLab interface.

While it is possible to open the script file in any HTML or text editor, changing the script file outside the PluginLab interface is likely to make the script unusable by the interface.

Any problems you experience if you do make changes directly in the script file are not supported by PluginLab.

In addition, the scripts are copyrighted by PluginLab and are not open-source code.

 

For more information see: