How to Use JavaScript Maker

ZDNet Downloads         

First, decide what content you wish to dynamically control. Using your favorite editor, copy just the code you want to convert and paste into a new file. Do not include the <HTML> <HEAD> </HEAD> <BODY> </BODY> </HTML> tags in this file. If you haven't already done so, please look at the example of JavaScript Maker at work, to see how it's done.

Now you're ready to use JavaScript Maker to convert the file. Here's what the main screen looks like.

First, you indicate where the source HTML file is located. Once done, JavaScript Maker will suggest a target filename and a function name, based on the source filename. You may change these suggested names, if you like. You can also use the Get Source File and Select Target File buttons to navigate to specific files.

Press the Make Script button to create the JavaScript file. If the target file already exists, it will be over-written.

In the next section, JavaScript Maker will produce the code you need to include in the <HEAD> and <BODY> sections of the web pages that will call the functions. The <BODY> section will always be the same five lines of code, incorporating the Function Name you entered, on line three.

The <HEAD> section code can be constructed in a number of ways, depending on where the files will end up on your web server. There are three possible scenarios that are supported:

  1. The JavaScript files will be stored in the same folder as the web pages that load them and call their functions.

  2. The JavaScript files will be stored in a single folder, dedicated only for .js files.

  3. You will use a single JavaScript file that contains all the functions you need. You will copy and paste the functions from the files JavaScript Maker creates into this "master" JavaScript file.
Take your pick as to which methods to use. JavaScript Maker can handle all of them.To enter your preferences for each of the above methods, press the Set Server Paths button to open the following dialog box...

If you use Method 1, leave both the Fixed Server File and the Variable Server Path fields blank. Be sure to set the default path as Variable Path.

If you use Method 2, enter the appropriate path to the folder that will contain your JavaScript files, in the Variable Server Path field. Keep in mind that this path is relative to the locations of the web pages that load those files. For example, if your web pages were all in folders directly below the root level of your server, you might create a folder called "javascripts", also one level below the root. The correct setting for the Variable Server Path field, in this example, would be ../javascripts. Finally, set the default path as Variable Path.

If you use Method 3, enter the full path to the single JavaScript file you use, in the Fixed Server File field. Once again, this path is relative to the locations of the web pages that load those files. For example, if your web pages were all in folders directly below the root level of your server, you might create a folder called "javascripts", also one level below the root and you might decide to name the JavaScript file "functions.js". The correct setting for the Fixed Server File field, in this example, would be ../javascripts/functions.js. Be sure to set the default path as Fixed File.

If you alternate between methods 2 and 3, then enter the appropriate values for each field. Press the Save button to store your settings and return to the main screen. The settings will be permanently saved, even if you exit the program, but you can change them, if needed. As a starting point, we have entered the paths, as pictured above, in the application.

On the main screen, select the option button which best serves your needs. If you select "Use fixed server file" the target filename will be ignored and whatever path and filename you entered as the fixed file will be used.

If you select "Use variable server path", the program will join the path you entered in the Set Server Paths dialog with the target filename (just the name portion, not the full path) from the main screen. If there is nothing entered in the Variable Server Path field it will only use the target filename.

If you switch option buttons, the <HEAD> section code will immediately change. Neither code window can be edited. This is a safety feature to avoid accidental mistakes.

You may then copy either section to the clipboard for pasting into your web pages. You may also copy both sections at the same time, in which case a line will be added above each section, indicating where it belongs.

Depending on how you organize and manage the JavaScript functions and files, you may want to load more than one JavaScript file on a particular web page because you need to call functions from both of them. You can load as many as you like by repeating the "loader" line for each file, in the <HEAD> section of your page. As an example...

<script language="JavaScript" SRC="../javascripts/NavBar.js"> <script language="JavaScript" SRC="../funnyscripts/todaysjoke.js">

will load two different script files from two different locations.

Similarly, you can call as many functions, consecutively, as needed. Put each function call on a separate line. The syntax is: FunctionName(); where FunctionName is (you guessed it) the name of the function. For example, if you wanted to call three functions, consecutively, named "Thoughts", "ContactInfo" and "NavBar", the code would look like this:

<script language="JavaScript">

If you need to separate your function calls with some HTML code, you must use the 5 lines that JavaScript Maker creates, for each call.

JavaScript Maker's only restriction is that the source code being converted has to be less than 25Kb. This figure will vary slightly, depending on the code being converted. In the unlikely event that your source file is larger, you can split it into two or more files, then create multiple functions to call, sequentially. This would be a very rare situation, indeed. If the source file is too big, JavaScript Maker will let you know.

Download JavaScript Maker, version 2.7 Download the full version (2.85 Mb) and if you like it, unlock it!.

After the download has finished, unzip the files. Then, run jsc27.exe to launch the setup program. When you're ready, here's How to Unlock JavaScript Maker.

<-- Back to Home Page