SEARCH
0-9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
Prev | Current Page 1937 | Next

Joseph W. Lowery

"Dreamweaver CS3 Bible"

To better understand how
deleteBehavior() is used, it??™s best to look at a couple of examples.
Two standard behaviors, Play Sound and Swap Image, use the deleteBehavior() function. Play Sound
inserts an tag that contains a unique ID. To remove the code, deleteBehavior() first reads a
function call string, just like the one returned by applyBehavior(). If the function finds an
tag with the matching ID that is not referenced elsewhere on the page, the code is deleted. Here??™s the implementation
of deleteBehavior() for Play Sound:
function deleteBehavior(fnCallStr) {
var argArray,sndName,doc,tagArray,i,embedName;
argArray = extractArgs(fnCallStr);
if (argArray.length > 3) {
//remove ???document.???, use unique name
sndName = dreamweaver.getTokens(argArray[2],???.???)[1];
//Find all EMBED calls that we created (name starts with ???CS???),
doc = dreamweaver.getDocumentDOM(???document???); //get all
tagArray = doc.getElementsByTagName(???EMBED???);
for (i=0; iembedName = tagArray[i].name;
if (embedName == sndName) { //if same embed
if (numOccurences(sndName)<2) { // and embed ref??™d no where else
tagArray[i].outerHTML = ??????; //delete the embed
break;
} } } }
}
Swap Image doesn??™t insert additional or other tags; it inserts additional event handlers to make
implementing rollovers a one-step process.


Pages:
1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946