0

我正在使用 amp-script 在我的 AMP 页面上创建动画。

var sentences = ["I‘m not getting any impressions", "I‘m getting impressions but no clicks", "I‘m getting clicks but no conversions", "My wasted spend is increasing", "My keywords are not performing", "My cost per click is increasing", "My ad is not showing in the top position", "My ROI is declining"];
var index = 0;
var reverse = false;
setInterval(myTimer1, 1);

function myTimer1() {
  if (!reverse) {
    sleep(120);
  } else {
    sleep(60);
  }
  sentenseAnimation(sentences[index]);
}

function sentenseAnimation(sentense) {
  if (document.querySelector(".txtex").innerHTML == "") {
    sleep(1000);
  }
  var s = document.querySelector(".txtex").innerHTML;
  if (s.length != sentense.length && !reverse) {
    s = s + sentense.charAt(s.length)
  } else {
    if (!reverse) {
      sleep(1000);
    }
    reverse = true
    s = s.slice(0, -1);
    if (s.length == 0) {
      reverse = false;
      if (index < sentences.length - 1) {
        index++;
      } else {
        index = 0;
      }
    }
  }
  document.querySelector(".txtex").innerHTML = s;
}

function sleep(delay) {
  var start = new Date().getTime();
  while (new Date().getTime() < start + delay);
}

动画运行流畅,但 5 到 6 小时后动画停止并在 amp-script.js 中出现错误(无法在 'Node' 上执行 'insertBefore':此节点类型不支持此方法)。 在此处输入图像描述

4

0 回答 0