Macromedia dreamweaver 8-extending dreamweaver User Manual

Page of 504
The Objects API
161
The Objects API
This section describes the functions in the Objects API. You must define either the 
insertObject()
 or the 
objectTag()
 function. For details about these functions, see 
. The remaining functions are optional.
canInsertObject() 
Availability
Dreamweaver MX.
Description 
This function determines whether to display the Object dialog box. 
Arguments
None. 
Returns 
Dreamweaver expects a Boolean value.
Example 
The following code tells Dreamweaver to check to see that the document contains a particular 
string before allowing the user to insert the selected object:
function canInsertObject(){    
   var docStr = dw.getDocumentDOM().documentElement.outerHTML;
   var patt = /hava/;
   var found = ( docStr.search(patt) != -1 );
   var insertionIsValid = true; 
 
   if (!found){
    insertionIsValid = false;
    alert("the document must contain a 'hava' string to use this object.");}
   return insertionIsValid;} 
displayHelp()
Description
If you define this function, it displays a Help button below the OK and Cancel buttons in the 
Parameters dialog box. This function is called when the user clicks the Help button.
Arguments
None.