Document Creation
Document Creation, Document Creation |
JavascriptJavaScript is a useful programming language that we can leverage to create more interactive and dynamic web pages. While the instructions presented here are fairly simple, they are recommended for document writers that are a bit more tech savvy, rather than general use. In the example here we'll be creating text that changes an image when the text is moused over, and then changed back when the mouse leaves the text. Our implementation will be split into a JavaScript and HTM file, and will then be put together by DynaDoc. JavaScript FileIf you don't already have one, create a folder named javascript in your project folder. In the javascript folder, create a text file. Rename the text file to have the same name as the HTM page you want to include JavaScript on. The file extension for JavaScript files is .js. If your HTM page is "software_cockpit.htm", your javascript file should be "software_cockpit.js". We'll start with a useful example. We'll use Javascript to preload some images and then have an image swap between different highlights when the relevant text is moused over. Let's take a look at the JavaScript file first. Not a lot of text, but most of it doesn't make sense on it's own. Let's explain what's going on.
Make sure that you set the names and paths correctly. Next, we'll take a look at the htm file that implements the JavaScript. HTM FileThis might look a bit more intimidating at first glance, but most of it is just regular text. Let's take a look at the relevant parts for the image.
DynaDoc Script FileWe separate the HTM and JavaScript files for ease of use, but we need to combine them to display a proper webpage. DynaDoc is built to do this for us. One of the fields we discussed earlier is used to include a JavaScript file. Here's an example of a page with an included JavaScript file in the DynaDoc script. **,Device Configuration,,software_device.htm,software_device.js,, The JavaScript include is one field after the htm file. If the file has incorrect comma placement it will not read correctly, so make sure to double check the syntax. |
Document Path: Document Creation Manual > Content Creation > JavaScript