Skip to content Skip to sidebar Skip to footer

Can't Get Simple Adsafe Widget To Work

I'm trying to use Douglas Crockford's ADsafe library. I thought it is supposed to restrict the JavaScript that can be used, but it seems to be letting dangerous calls through, such

Solution 1:

As far as I can tell, ADsafe does not actually check your code for these violations. You are expected to use JSLint with ADsafe options enabled, to parse any untrusted JavaScript and verify that there are no ADsafe violations, before using it.

Anyone, please correct me if this is wrong.

Solution 2:

The code is inside the div, so the code is executed before the div is fully loaded, and it apparently does not work in that case. Moving the script outside and after the div works: http://jsfiddle.net/pimvdb/dFQQa/.

<html><head><title>ADsafe Widget Template</title></head><body><scriptsrc="adsafe.js"></script><divid="WIDGET_"></div><!-- div has been ended and fully loadede by now --><script>ADSAFE.go("WIDGET_", function (dom, lib) {
            "use strict";

            // // ADsafe is allowing these to execute!!// window.alert("window alert is working :(");
            eval('window.alert("hello from eval")');
            window.location = "http://www.google.com";
        });
    </script></body></html>

Post a Comment for "Can't Get Simple Adsafe Widget To Work"