发生“视频广告跳过”按钮事件时,焦点无法转移到iframe游戏

时间:2019-04-01 13:07:44

标签: javascript video-ads

我的网站上有一些视频广告。展示视频广告后(发生ima.adevent.type.complete),游戏将键盘焦点对准以下代码。   但是,如果通过单击“跳过”按钮跳过视频广告,则不能正确地将焦点赋予游戏,这意味着在以下代码中出现了google.ima.AdEvent.Type.SKIPPED。

case google.ima.AdEvent.Type.SKIPPED:
  case google.ima.AdEvent.Type.COMPLETE:
  // This event indicates the ad has finished - the video player
  // can perform appropriate UI actions, such as removing the timer for
  // remaining time detection.
  if (ad.isLinear()) {
    clearInterval(intervalTimer);
  }
  focusWhenReady = function () {
    doc = iframe.contentDocument || iframe.contentWindow.document;
    if (doc.readyState == "complete") {
      iframe.contentWindow.focus();
      console.log('code comes here in both cases ...');
    } else {
      setTimeout(focusWhenReady, 200)
    }
  }
  setTimeout(focusWhenReady, 100);

0 个答案:

没有答案