Macromedia dreamweaver 8-extending dreamweaver User Manual

Page of 504
A simple insert object example
151
Creating 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.
To create the HTML file:
1.
Create a new blank file.
2.
Add the following code:
<html>
<head>
<title>Strikethrough</title>
<script language="javascript">
</script>
</head>
<body>
</body>
</html>
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 i
sDOMRequired()
, 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.
To 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:
<script language="javascript">
function isDOMRequired() {
// Return false, indicating that this object is available in Code 
view.
return false;
}
</script>
2.
Save the file.