Loading ...
Sorry, an error occurred while loading the content.

Re: ADsafe

Expand Messages
  • adam.kumpf
    ... . ... developers. ... Thanks Doug -- it s great that you are so responsive! One word of caution, though. From the returned
    Message 1 of 36 , May 10, 2010
    • 0 Attachment
      --- In caplet@yahoogroups.com, "Douglas Crockford" <douglas@...> wrote:
      >
      > I added a getContext method. It makes it possible to draw on a <canvas>.
      >
      > I am now logging all errors to ADSAFE.log as a convenience for developers.
      >


      Thanks Doug -- it's great that you are so responsive!

      One word of caution, though.  From the returned CanvasRenderingContext2D it is possible to access the raw HTML Canvas element, which in turn allow access up the DOM (ahhh!). 

      Is there a way to override the canvas variable within the CanvasRenderingContext2D such that it cannot be accessed?

      Here's the code I was running that allowed me to get up the DOM:

      ---------------------------------------

      <!-- BEGIN ADSAFE WIDGET FRAGMENT -->
      <div id="TEMPLATE_">
      <canvas id="TEMPLATE_CANVAS">
      Default canvas content if browser doesn't support it.
      </canvas>
      other html markup required by the widget goes here
      <script>
      "use strict";
      ADSAFE.id("TEMPLATE_");
      </script>
      <!-- LIBS HERE-->
      <script>
      "use strict";
      ADSAFE.go("TEMPLATE_", function (dom, lib) {
      // This is where the code for the widget is placed.
      var tc = dom.q("#TEMPLATE_CANVAS");
      var context = tc.getContext('2d');
      ADSAFE.log(context);
      var docsBody = context.canvas.offsetParent; // potentially dangerous!!
      ADSAFE.log(docsBody);
      });
      </script>
      </div>
      <!-- END ADSAFE WIDGET FRAGMENT -->

      ---------------------------------------

      Cheers,
      Adam




    • Douglas Crockford
      I updated the ADsafe DOM interface. Previously, a method like .getValue() could return undefined a single value an array of values depending on the number of
      Message 36 of 36 , Nov 11, 2010
      • 0 Attachment
        I updated the ADsafe DOM interface. Previously, a method like .getValue() could return

        undefined
        a single value
        an array of values

        depending on the number of results. Now, a method like .getValue() will return the first value that is available, or undefined if there are none. A new method, .getValues() will always return an array, possibly an empty array.
      Your message has been successfully submitted and would be delivered to recipients shortly.