# Class AdDisplayContainer

*** ** * ** ***


This class represents a container for displaying ads. The SDK will automatically create
structures inside the containerElement parameter to house video and overlay ads.


When an instance of this class is created, it creates an IFRAME in the containerElement
and loads the SDK core. This IFRAME must be preserved in order for the SDK to function
properly. Once all ads have been played and the SDK is no longer needed, use the
`destroy()` method to unload the SDK.


The containerElement parameter must be an element that is part of the DOM. It is necessary
to correctly position the containerElement in order for the ads to be displayed correctly.
It is recommended to position it above the content video player and size it to cover the
whole video player. Refer to the SDK documentation for details about recommended
implementations.


**Note:** It is always necessary to call the `initialize()` method in code
that was directly invoked by a user action (such as a click or tap).

| Constructors ||
|---|---|
| `https://developers.google.com/interactive-media-ads/docs/sdks/html5/client-side/reference/class/google.ima.AdDisplayContainer#google.ima.AdDisplayContainer.constructor` | Constructor. |

| Methods ||
|---|---|
| `https://developers.google.com/interactive-media-ads/docs/sdks/html5/client-side/reference/class/google.ima.AdDisplayContainer#google.ima.AdDisplayContainer.destroy` | Destroys internal state and previously created DOM elements. |
| `https://developers.google.com/interactive-media-ads/docs/sdks/html5/client-side/reference/class/google.ima.AdDisplayContainer#google.ima.AdDisplayContainer.initialize` | Initializes the internal video elements for playback. |

## Constructors

*** ** * ** ***

### constructor

`new AdDisplayContainer(containerElement: Element, videoElement?: HTMLVideoElement, clickTrackingElement?: Element): https://developers.google.com/interactive-media-ads/docs/sdks/html5/client-side/reference/class/google.ima.AdDisplayContainer` Constructor.

| Parameters ||
|---|---|
| `containerElement: Element` | The element to display the ads in. The element must be inserted into the DOM before creating AdDisplayContainer. |
| `` `Optional` videoElement: HTMLVideoElement `` | Specifies the alternative video ad playback element. We recommend always passing in your content video player. |
| `` `Optional` clickTrackingElement: Element `` | Specifies the alternative video ad click element. Leave this null to let the SDK handle clicks. Even if supplied, the SDK will only use the custom click tracking element when non-AdSense/AdX creatives are displayed in environments that do not support UI elements overlaying a video player (for example, iPhone or pre-4.0 Android). **The custom click tracking element should never be rendered over the video player** because it can intercept clicks to UI elements that the SDK renders. Also note that the SDK will not modify the visibility of the custom click tracking element. This means that if a custom click tracking element is supplied, it must be properly displayed when the linear ad is played. You can check google.ima.AdsManager.isCustomClickTrackingUsed when the google.ima.AdEvent.Type.STARTED event is fired to determine whether or not to display your custom click tracking element. If appropriate for your UI, you should hide the click tracking element when the google.ima.AdEvent.Type.CONTENT_RESUME_REQUESTED event fires. |

| Returns ||
|---|---|
| `https://developers.google.com/interactive-media-ads/docs/sdks/html5/client-side/reference/class/google.ima.AdDisplayContainer` |   |

## Methods

*** ** * ** ***

### destroy

`destroy(): void` Destroys internal state and previously created DOM elements. The IMA SDK will be unloaded and no further calls to any APIs should be made.

*** ** * ** ***

### initialize

`initialize(): void` Initializes the internal video elements for playback. You must call this method as a direct result of a user action, so that the browser can mark the video element as user initiated.  

Some browsers will allow video playback without user interactions if the video is muted. For this behavior, use `AdsRequest.setAdWillPlayMuted(true)` and call this method before `AdsManager.start()`.