NitroAd
NitroAd placement.
Constructors
new NitroAd(id: string, options: NitroAdOptions): NitroAd
Parameters
id(string) — placement idoptions(NitroAdOptions) — Placement settings
Returns
NitroAd
Properties
id: string
The unique id attribute for this placement.
options: NitroAdOptions
Placement settings.
Methods
canReuse(createKey: string): boolean
True if a duplicate createAd can keep this placement instead of destroying it: the request is still in flight and the page, element and options are unchanged. Destroying it would cancel the in-flight request (e.g. remove Scalibur's isolated iframe while its loader waits on consent) only to start the same request again.
Parameters
createKey(string) — JSON of the options passed to createAd
Returns
boolean
clear(keepHighImpact: boolean): void
Parameters
keepHighImpact(boolean, default: "false") — leave the high-impact slot in place, it may be the one showing the current skin
Returns
void
frameContainers(): (HTMLElement | null)[]
Elements whose iframes may post high-impact messages for this placement: its own element and its high-impact GAM slot.
Returns
(HTMLElement | null)[]
getState(): AdState | null
Lifecycle state of this placement's most recent ad request, or null if no request has started yet.
Returns
AdState| null
onNavigate(href?: string): void
In single-page applications, this can be called to clear and refresh the placement when navigating to a different URL. Passing in a href prop for an interstitial format will navigate to the given href after the interstitial is dismissed.
Remarks
In an SPA, where navigating to a new page doesn't trigger a full page refresh, you can keep a reference to the NitroAd object you receive when calling createAd, and call this from your framework's navigation event.
Alternatively, you can remove the container div from the DOM, then recreate it and call createAd again. The div being removed will be detected, and any related resources will be freed.
Parameters
href(string, optional)
Returns
void
renderContainers(): Promise<boolean>
returns true if ad rendering should continue returns false if ad rendering should be halted
Returns
Promise<boolean>— boolean
suspendForSkin(): void
Empties the placement while a skin shows on a skin-exclusive site. resumeAfterSkin() renders it again.
Returns
void
videoConfig(cfg: VideoPlayerConfig): void
Merge config into the live Aniview video player in real time. Only valid on video or video-nc format placements — logs an error otherwise. Safe to call at any time after the unit renders; calling before the player is initialized is a no-op (the Aniview module will log a warning).
Parameters
cfg(VideoPlayerConfig)
Returns
void
Example
const ad = await window.nitroAds.createAd('unit-1', { format: 'video', ... });
ad.videoConfig({ floating: { top: 80 } });