vishnu vishnu - 3 months ago 18
HTML Question

How can I prevent Dreamweaver from running local code?

I'm trying to stop Dreamweaver from executing code when I open HTML files. Because the program hangs up for a long period of time when I open multiple files.

In preferences, I have set Dreamweaver to not open any related or linked files, but any local code still executes.

For example, in the image below, the lines that call

eval
are being executed:

1

Is there a way I can have Dreamweaver not execute this code without commenting it out?

Answer

One way is to check the useragent for Dreamweaver, and prevent code execution if it matches. Matching against 'Dreamweaver/' in the user agent should work:

if ( navigator.userAgent.indexOf('Dreamweaver/') === -1 )
{
    //Your eval code blocks here.
}

Chris from Dreamweaver Engineering, posted in this thread the user agents of dreamweaver:

Mac: "Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en) AppleWebKit/530.19.2 (KHTML, like Gecko) Dreamweaver/11.0.m.bbbb Version/4.0.2 Safari/530.19.2"

Windows: "Mozilla/5.0 (Windows; U; en) AppleWebKit/530.19.2 (KHTML, like Gecko) Dreamweaver/11.0.m.bbbb Version/4.0.2 Safari/530.19.2"

Here's a simple code snippet showing its usage:

var isNotDreamweaver = navigator.userAgent.indexOf('Dreamweaver/') === -1;

console.log(isNotDreamweaver ? 'You\'re not running dreamweaver.' : 'You\'re running dreamweaver.');
console.log('Current User Agent: ', navigator.userAgent);