Export (0) Print
Expand All

JavaScript Callback Events - Windows 8.1

Microsoft Advertising Services

Published: April 1, 2014

In the HTML5 (JavaScript) and JavaScript Without HTML5 Tags examples, there are optional events that you can handle in code. The following snippets provide examples of how to define them.

The AdControl events must be enclosed by the MarkSupportedForProcessing function.

The snippets assume you have assigned the events to their event handlers, either in an HTML or JavaScript file. For example: myAdControl.onErrorOccurred = myAdError.

Example


WinJS.Utilities.markSupportedForProcessing(
window.myAdError = function (sender, msg) {
  // place code here for when there is an error serving an ad.
  // e.g. you may opt to show a default experience, or reclaim the div for other purposes.
});

WinJS.Utilities.markSupportedForProcessing(
window.myAdRefreshed = function (sender) {
  // place code here that you wish to execute when the ad refreshes.
});

WinJS.Utilities.markSupportedForProcessing(
window.myAdEngagedChanged = function (sender) {
  if (true == sender.isEngaged) {
    // code here for when user engaged with ad, e.g. if a game, pause it.
  }
  else {
    // user no longer engaged with ad, include code to unpause.
  }
});

Support and Feedback

Get product support or report a bug in the advertising SDK by visiting the Windows Store Apps developer support page support page. For product support, under "App development" click the "Advertising SDK" link. To post a question in the support forum, scroll down to "Find answers online" and click "Ads-in-Apps for Windows 8 forum".

Send feedback about this documentation to adsfdbk@microsoft.com. There is no product support through this alias. Documentation feedback only.

Community Additions

ADD
Show:
© 2014 Microsoft