Screenad Interface: Methods and Properties

Method Details
Misc.
addEventListener(event_name, callback)

Registers a callback that will listen to a specific Screenad Interface event.

This function cannot be used for DOM events.

See: Event details.

Parameters:
{String} event_name
The event which will be listened to.
{Function} callback
The function that will be called when the specified event takes place.
angle(innerX, innerY, outerX, outerY) : {Number}
Calculates the angle between two points
Parameters:
{Number} innerX
The inner x coordinate
{Number} innerY
The inner y coordinate
{Number} outerX
The outer y coordinate
{Number} outerY
The outer x coordinate
Returns:
{Number} angle
Misc.
blockTouches() deprecated
Once activated, all touches to the browser are no longer propagated to the main page, disabling scrolling and interaction with the website.
Enable this if your ad contains features like swiping, pinch zooming, drawing, etc.

Be sure to call unblockTouches when needed, to allow the user to interact with the main page again.
Deprecated:
Will be deprecated in SI 1.0.4. Please use ‘screenad.setBlockPageTouches(true)’ instead.
See:
screenad#setBlockPageTouches
UserInteraction
click(click)
Opens the exit URL that is related to the specified ‘click’ parameter.
Parameters:
{String} click Optional, Default: “default”
Reference string, e.g.: ‘default’, ‘extra1’, ‘extra2’, etc.
Screenad
close(target)
Closes the specified target
Parameters:
{String} target Optional, Default: “self”
Specifies which element(s) should be closed.
conf(key, value)
Triggers custom display script configuration variables, such as: env, form, ignorepos, ignorehide. These settings are normally used by Weborama employees only.
screenad.conf(key:String, value:Boolean);
Parameters:
{String} key
The key part of the configuration setting. E.g.: form, ignorepos
{Boolean|String} value
The new value of this configuration setting. Accepts true, false, auto.
UserInteraction
createCalendarEvent(date, title, description)
Creates an event in the user’s calendar*.

*Works on phones inside applications that are ORMMA/MRAID compatible
Parameters:
{Date} date
Date of the calendar event.
{String} title
Title of the calendar event.
{String} description
Description of the calendar event.
distance(innerX, innerY, outerX, outerY) : {Number}
Returns the mouse distance to the top-left of this ad
Parameters:
innerX
innerY
outerX
outerY
Returns:
{Number} The distance
Reporting
event(event)
Sends reporting event to Weborama servers
Parameters:
{String} event
The name of the event, e.g.: ‘user_close’ ([A-Za-z0-9_]).
Misc.
executeScript(script, callback)
Executes JavaScript in the scope of the website.
Parameters:
{String} script
The script that should be executed, as a string.
{Function} callback Optional
The function that should be called when the script has executed.
Screenad
hide(target)
Hides the specified target
Parameters:
{String} target Optional, Default: “self”
Specifies which element(s) should be hidden.
Positioning
hideNavBar()
This hides the address bar on mobile phones, by scrolling 1px down, if the current scroll position is 0
Misc.
log(Object)
This log function is used to give feedback to developers.
Parameters:
Object
message The message that should be conveyed.
UserInteraction
makeCall(phone_number)
Make a phone call to the specified number*.

*Works on phones in browser environments and inside applications that are ORMMA/MRAID compatible
Parameters:
{String} phone_number
The number to dial.
 mergeObjects(target, source)
Creates a clone of an object for cases where you wish to change a copy of any object, instead of the reference to an Object
Parameters:
{Object} target
The object we should ‘dress up’ with the methods and properties of the source
{Object} source
The source object
mouseAngle() : {Number}
Gets the mouse angle to the environment clip
mouseAngleTo(x, y) : {Number}
Calculates the mouse angle to the environment clip
Parameters:
{Number} x
Horizontal coordinate; used to calculate mouse angle
{Number} y
Vertical coordinate; used to calculate mouse angle
Returns:
{Number} angle
mouseDistance() : {Number}
Gets the mouse distance from the top-left corner of the ad
mouseDistanceTo(x, y) : {Number}
Calculates the mouse distance from a custom coordinate
Parameters:
{Number} x
The x position
{Number} y
The y position
Returns:
{Number} Distance in pixels
Positioning
position(scene_string)
IMPORTANT: Sends positioning data to the Weborama Display Scripts. All data that is set using the other positioning functions (setClip, setAlignment, etc.) is not sent to the Display Scripts, unless this function is called.
Parameters:
{String} scene_string Optional
Screenad
postclick()
If this function is called, we wait for a user to click on a link before showing this layer.
Screenad
proceed()
If a postclick is activated, the proceed function tells the browser to continue navigating to the link on which the user clicked.
Misc.
removeEventListener(event_name, callback)
Removes a Screenad Interface event listener.
Parameters:
{String} event_name
The event which will be listened to.
{Function} callback
The function that will be called when the specified event takes place.
Screenad
resize(width, height, target)
Resizes the specified target
Parameters:
{String} width
Width
{String} height
Height
{String} target Optional, Default: “self”
Specifies which element(s) should be resized.
UserInteraction
sendMail(recipient, subject, body, cc, bcc)
Sends an e-mail to the specified recipient*.

*Works on phones inside applications that are ORMMA/MRAID compatible
Parameters:
{String} recipient
E-mail address of the recipient.
{String} subject
Subject of the e-mail.
{String} body
The content of the e-mail.
{String} cc Optional
{String} bcc Optional
UserInteraction
sendSMS(recipient, text_body)
Send a text message to the specified recipient*.

*Works on phones in browser environments and inside applications that are ORMMA/MRAID compatible
Parameters:
{String} recipient
The name of the variable.
{String} text_body
The content of the text message. (Predefined SMS content is not supported on Android 2.X native browser and iOS 7+)
Positioning
setAlignment(horizontal_align, vertical_align)
Decides to what anchor point on the page this layer will align.
Parameters:
{String} horizontal_align
Possible values: ‘left’, ‘center’, ‘right’, ‘banner’, ‘#{html_element_id}’, ‘{other_layer_name}’.
{String} vertical_align
Possible values: ‘top’, ‘center’, ‘bottom’, ‘banner’, ‘#{html_element_id}’, ‘{other_layer_name}’.
Positioning
setAntiZoom(anti_zoom)
When anti-zoom is set to true, 2 things happen.
  1. The original layer dimensions are visually maintained, regardless of the zoom level the browser.
  2. The layer will align to the visual viewport*.
*see http://www.quirksmode.org/mobile/viewports2.html
Parameters:
{Boolean} anti_zoom
Misc.
setBlockPageTouches(block)
Enable or disable touch propagation to the main page, disabling scrolling and interaction with the website.
Use “setBlockPageTouches(true)” this if your ad contains features like swiping, pinch zooming, drawing, etc.

Be sure to call “setBlockPageTouches(false)” if this behavior is no longer needed, to allow the user to interact with the main page again.
Parameters:
{Boolean} block
Should touches to the page be blocked?
Positioning
setClip(clipx1, clipy1, clipx2, clipy2)
When clipping is applied to a layer, only the specified (rectangular) part of this layer will be shown.
Parameters:
{String|Number} clipx1
x1 coordinate for clipping.
{String|Number} clipy1
y1 coordinate for clipping.
{String|Number} clipx2
x2 coordinate for clipping.
{String|Number} clipy2
y2 coordinate for clipping.
Misc.
setElementZoom(element, zoomLevel)
Manually sets the zoom level of an HTML element (includes cross-browser fixes).
//Instead of:
myElement.style.zoom = '150%';
//Use this:
screenad.setElementZoom(myElement, 1.5);
Parameters:
{HTMLNode} element
Element to which the zoom level should be applied.
{Number} zoomLevel
Zoom level that should be applied to the element. (Use 1.0 for 100% zoom)
Positioning
setHideElements(hide)
Decides if website elements that burn through layers should be automatically hidden when the layer overlaps them.
Parameters:
{Boolean} hide
Positioning
setOffset(offset_x, offset_y)
The offset to the alignment, which is set using screenad#setAlignment.
Parameters:
{Number} offset_x Optional, Default: 0
The offset from the horizontal alignment point.
{Number} offset_y Optional, Default: 0
The offset from the vertical alignment point.
Screenad
setPreloaded()
Use this function to manually call the preload command. By default, this function is called automatically when this iframe’s content has loaded. If you wish to override the default behavior for some reason, disable the screenad.conf_autopreload. The preload command will only be executed once per impression.
Positioning
setSize(width, height)
Sets the size of this layer’s scene. The original size dimensions are not updated.
Parameters:
{String|Number} width
Number or percentage that represents the new layer width.
{String|Number} height
Number or percentage that represents the new layer height.
Positioning
setSmooth(smoothness)
When set to a number higher than 0, the layer is gradually moved to its new position.
Parameters:
{Number} smoothness
Decides the speed of the transition. 0 is instant, 100 is slow.
Positioning
setSticky(sticky)
Decides if this layer should stick to the scrollbar or not.
Parameters:
{Boolean} sticky
Communication
setVariable(name, value, target)
Sends a variable to the specified element(s).
Parameters:
{String} name
The name of the variable.
{String} value
The value of the variable.
{String} target Optional, Default: ‘all’
Specifies which element(s) should receive this variable (‘banner’,’self’,’all’,'{LAYER_NAME}’).
Positioning
setZIndex(zindex)
Set the z-index of a layer.

Usage:
screenad.setZIndex(200)
Parameters:
{Number} zindex
Screenad
show(target)
Shows the specified target
Parameters:
{String} target Optional, Default: “self”
Specifies which element(s) should be shown.
Reporting
startTimer(timer_name)
Starts counting the duration of a specific user interaction, A.K.A. a timer event — timer events are used to measure how much time a user spends performing a specific action, e.g: the expand time. Be sure to always call screenad#stopTimer to stop counting the interaction time, otherwise the timer will keep running for the rest of the session. We automatically keep score of (among others) the following timers: visibility, expand duration, video play duration.
Parameters:
{String} timer_name
The name of the timer event, e.g.: ‘gameplay_duration’ ([A-Za-z0-9_]).
See:
screenad#stopTimer
Reporting
stopTimer(timer_name)
Pauses the counting the duration of a specific user interaction, A.K.A. a timer event — timer events used to measure how much time a user spends performing a specific action, e.g.: the expand time. Be sure to always call screenad#stopTimer to stop counting the interaction time, otherwise the timer will keep running for the rest of the session. We automatically keep score of (among others) the following timers: visibility, expand duration, video play duration.
Parameters:
{String} timer_name
The name of the timer event, e.g.: ‘gameplay_duration’ ([A-Za-z0-9_]).
See:
screenad#startTimer
Environment
supportsTilt() : {Boolean}
Does this device support using the gyroscope.
Misc.
unblockTouches() deprecated
Disables the blocking of touches. See: screenad#blockTouches for more info.
Deprecated:
Will be deprecated in SI 1.0.4. Please use ‘screenad.setBlockPageTouches(false)’ instead.
See:
screenad#setBlockPageTouches
Screenad
wallpaper(wallpaper_url, wallpaper_position)
The `screenad.wallpaper` command allows you to set a background on the `BODY` element of a web page. This command should only be used with the publishers permission. Or if it was found in one of our publisher specific templates.

The background image isn’t clickable. If you wish to have a wallpaper with interaction you should use interactive skins. The templates for interactive skins are available on request.
Parameters:
{String} wallpaper_url
The (relative) wallpaper image URL, e.g.: ‘wallpaper.jpg’
{String} wallpaper_position
Configuration for the wallpaper position, e.g.: ‘center top no-repeat’