If the translateMarkup() function contains certain types of errors, the translator loads properly, but it fails without an error message when you invoke it. Although failing silently prevents Dreamweaver from becoming unstable, it can hinder development, especially when you need to find one small syntax error in multiple lines of code.
If your translator fails, one effective debugging method is to turn the translator into a command, as described in the following steps:
-
function commandButtons(){ return new Array( "OK","translateMarkup(dreamweaver.¬ getDocumentPath('document'), dreamweaver.getSiteRoot(), ¬ dreamweaver.getDocumentDOM().documentElement.outerHTML); ¬ window.close()", "Cancel", "window.close()"); }
-
At the end of the translateMarkup() function, comment out the returnwhateverTheReturnValueIs line, and replace it with dreamweaver.getDocumentDOM().documentElement.outerHTML = whateverTheReturnValueIs, as shown in the following example:
// return theCode; dreamweaver.getDocumentDOM().documentElement.outerHTML = theCode; } /* end of translateMarkup() */
-
Add alert() statements in strategic spots throughout the translateMarkup() function so you can make sure you’re getting the proper branches and so you can check the values of variables and properties at different points:
for (var i=0; i< foo.length; i++){ alert("we're at the top of foo.length array, and the value of i is " + i); /* rest of loop */ }