From September, Flash will no longer be supported by Chrome. Prepare for the shift towards HTML5 by visiting our Flash to HTML5 help page

Check it out!

Public Methods

Public methods are for assets:

  • dhtml.getVar(name, undefined_fallback) - returns string value of a banner variable with name (flashvars) or provided default value if variable does not exist. Example how get clickTAG and landingPageTarget variables values from system if not present - use default:

    clickTAGvalue = dhtml.getVar('clickTAG', 'http://test.page.com/');
    landingPageTarget = dhtml.getVar('landingPageTarget', '_blank');
  • dhtml.sendEvent(id, name, vars) - registers event in Adform system;
    If sending custom event id must be in range from 1 to 19.  name argument is required and vars object is optional.
    vars object example: { bv1: 'John', bv2: 'Malcolm' }

    button.onclick = function() {
                    var id = 1,
                    name = 'banner click',
                    eventVars = {
                        bv1: "John",
                        bv2: "Colin",
                        bv3: "24"
                    };
    
                dhtml.sendEvent(id, name, eventVars);
                return false;
            };
  • dhtml.getAsset(id) - returns URL of an asset with the given id, or 'undefined' if that asset doesn't exist. 
    var url = dhtml.getAsset(1); //A call to the function with the asset id.
  • dhtml.inscreen - use this object to track banner in-screen parameters from asset.

    Methods:

    • on(type, callback) - add event listener.
    • once(type, callback) - add event listener, and remove after it fires.
    • off(type, callback) - remove event listener.

    Events:

    • 'visible' - fires when banner visible parameter changes.
    • 'percent' - fires when banner percent parameter changes.
    • 'change' - fires when any banner parameter changes.

    Note: Every event (except 'change') passes value argument to its callback. This argument holds latest banner in-screen parameter value.

    Properties:

    • visible (Boolean) - holds value whenever banner is visible or not (true or false).
    • percent (Number) - holds banner visibility percent value (from 0 to 100).

    Code Examples:

      dhtml.inscreen
        .on('visible', function (value) { console.log('visible change', value); })
        .on('percent', function (value) { console.log('percent change', value); })
        .on('change', function () {
          console.log('some change', {
            visible: this.visible,
            percent: this.percent
          });
        });
  • dhtml.external.
    • expand() – expand banner from asset (used in axpandable banner types)
    • close() – collapse or close floating banner
    • superClose() – close and destroy entire banner
    • initPoliteMode() – announce that asset is ready to load heavy content (used with dhtml.sharedEvents.on('pageLoadComplete', listener))
    • updateBox(x, y, width, height) – used by Adform.SingleExpanding
    • expandComplete() – used by Adform.SingleExpanding
    • collapseComplete() – used by Adform.SingleExpanding
    • initScroll() - Will be used by Adform.FilmStrip
    • initSingleExpanding(x, y) – used by Adform.SingleExpanding
    • toggleFullScreen(status) – used by Adform.VideoPlayer

These methods are for an interacting banner.

  • includeAPI() - method that loads Adform.DHTML.js file from appropriate Adform servers. All it does is just document writing the script, ex.:
doc.write('<script src="'+fv.staticDomain + 'scripts/rmb/Adform.DHTML.js?bv='+ fv.bv+'"><\/script>');