Create the html file, Adding the javascript functions – Adobe Extending Dreamweaver CS4 User Manual
Page 119
113
EXTENDING DREAMWEAVER CS4
Insert bar objects
Because this example performs text manipulation, you may want to explore some of the objects from the Text pop-up
menu in the HTML category on the Insert bar as models. For example, look at the Bold, Emphasis, and Heading object
files to see similar functionality, where Dreamweaver wraps a tag around selected text.
You will perform the following steps to create the strike-through insert object:
Create the HTML file
The title of the object is specified between the opening and closing
title
tags. You also specify that the scripting
language is JavaScript.
1
Create a new blank file.
2
Add the following code:
3
Save the file as Strikethrough.htm in the Configuration/Objects/Text folder.
Adding the JavaScript functions
In this example, the JavaScript functions define the behavior and insert code for the Strikethrough object. You must
place all the API functions in the head section of the file. The existing object files, such as
Configuration/Objects/Text/Em.htm, follow a similar pattern of functions and comments.
The first function the object definition file uses is
isDOMRequired()
, which tells whether the Design view needs to be
synchronized to the existing Code view before execution continues. However, because the Superscript object might be
used with many other objects in the Code view, it does not require a forced synchronization.
Add the isDOMRequired() function
1
In the head section of the Strikethrough.htm file, between the opening and closing
script
tags, add the following
function:
2
Save the file.
Next, decide whether to use
objectTag()
or
insertObject()
for the next function. The Strikethrough object simply
wraps the
s
tag around the selected text, so it doesn’t meet the criteria for using the
insertObject()
function (see