js循環遍歷彈框,先彈出第一個以後逐步彈出第二個。。

var data = [{
  "login_advertTitle": "即便生活瑣碎,也要活得優雅",
  "login_advertCont": "<html>\r\n<head>\r\n\t<title></title>\r\n</head>\r\n<body>\r\n<p style=\"padding: 10px 0px; margin: 0px; color: rgb(67, 67, 67); font-size: 16px; line-height: 2; text-indent: 2em; font-family: -apple-system, "PingFang SC", "Helvetica Neue", STHeiti, "Microsoft Yahei", Tahoma, sans-serif; background-color: rgb(255, 255, 255);\">Who can say that their lives are not insignificant?</p>\r\n\r\n<p style=\"padding: 10px 0px; margin: 0px; color: rgb(67, 67, 67); font-size: 16px; line-height: 2; text-indent: 2em; font-family: -apple-system, "PingFang SC", "Helvetica Neue", STHeiti, "Microsoft Yahei", Tahoma, sans-serif; background-color: rgb(255, 255, 255);\">  誰的生活不瑣碎呢?</p>\r\n\r\n<center style=\"padding: 0px; margin: 0px; color: rgb(51, 51, 51); font-family: -apple-system, "PingFang SC", "Helvetica Neue", STHeiti, "Microsoft Yahei", Tahoma, sans-serif; font-size: 16px; background-color: rgb(255, 255, 255);\"><img alt=\"惟美圖片\" height=\"371\" src=\"https://www.yueduwen.com/uploads/allimg/1802/1-1P20320593L18.jpg\" style=\"padding: 0px; margin: 0px 0px 10px; border: none; box-shadow: rgb(174, 174, 174) 2px 3px 3px;\" width=\"600\" /></center>\r\n\r\n<p style=\"padding: 10px 0px; margin: 0px; color: rgb(67, 67, 67); font-size: 16px; line-height: 2; text-indent: 2em; font-family: -apple-system, "PingFang SC", "Helvetica Neue", STHeiti, "Microsoft Yahei", Tahoma, sans-serif; background-color: rgb(255, 255, 255);\">  Everyone's life is composed with one after another insignificant day.</p>\r\n\r\n<p style=\"padding: 10px 0px; margin: 0px; color: rgb(67, 67, 67); font-size: 16px; line-height: 2; text-indent: 2em; font-family: -apple-system, "PingFang SC", "Helvetica Neue", STHeiti, "Microsoft Yahei", Tahoma, sans-serif; background-color: rgb(255, 255, 255);\">  咱們的一輩子,都是由這一個個瑣碎的一天構成的。</p>\r\n\r\n<p style=\"padding: 10px 0px; margin: 0px; color: rgb(67, 67, 67); font-size: 16px; line-height: 2; text-indent: 2em; font-family: -apple-system, "PingFang SC", "Helvetica Neue", STHeiti, "Microsoft Yahei", Tahoma, sans-serif; background-color: rgb(255, 255, 255);\">  Some people got their willpower abraded in this endless loop of days.</p>\r\n\r\n<p style=\"padding: 10px 0px; margin: 0px; color: rgb(67, 67, 67); font-size: 16px; line-height: 2; text-indent: 2em; font-family: -apple-system, "PingFang SC", "Helvetica Neue", STHeiti, "Microsoft Yahei", Tahoma, sans-serif; background-color: rgb(255, 255, 255);\">  有的人在這日復一日的循環中被消磨了意志。</p>\r\n\r\n<p style=\"padding: 10px 0px; margin: 0px; color: rgb(67, 67, 67); font-size: 16px; line-height: 2; text-indent: 2em; font-family: -apple-system, "PingFang SC", "Helvetica Neue", STHeiti, "Microsoft Yahei", Tahoma, sans-serif; background-color: rgb(255, 255, 255);\">  They think this is how things can only be like.<span class=\"yueduwencom\" style=\"padding: 0px; margin: -30px 0px 0px; position: relative; top: -5000px; left: -10000px; display: block;\">(<a href=\"http://www.yueduwen.com/\" style=\"padding: 0px; margin: 0px; color: rgb(0, 112, 192);\">悅讀文網</a> www.yueduwen.com)</span></p>\r\n\r\n<p style=\"padding: 10px 0px; margin: 0px; color: rgb(67, 67, 67); font-size: 16px; line-height: 2; text-indent: 2em; font-family: -apple-system, "PingFang SC", "Helvetica Neue", STHeiti, "Microsoft Yahei", Tahoma, sans-serif; background-color: rgb(255, 255, 255);\">  認爲一切也就這樣了。</p>\r\n\r\n<p style=\"padding: 10px 0px; margin: 0px; color: rgb(67, 67, 67); font-size: 16px; line-height: 2; text-indent: 2em; font-family: -apple-system, "PingFang SC", "Helvetica Neue", STHeiti, "Microsoft Yahei", Tahoma, sans-serif; background-color: rgb(255, 255, 255);\">  So they choose to reach a compromise and become mediocre. They become the background colors in others' eyes. They won't achieve anything great to be written down in history, nor can they bring any enjoyment to the people around them.</p>\r\n\r\n<p style=\"padding: 10px 0px; margin: 0px; color: rgb(67, 67, 67); font-size: 16px; line-height: 2; text-indent: 2em; font-family: -apple-system, "PingFang SC", "Helvetica Neue", STHeiti, "Microsoft Yahei", Tahoma, sans-serif; background-color: rgb(255, 255, 255);\">  因而他們選擇與平庸妥協,成爲別人眼中的背景顏色,不光不會在歷史上留下一筆偉績,甚至沒法爲身邊的人平添一抹色彩。</p>\r\n\r\n<p style=\"padding: 10px 0px; margin: 0px; color: rgb(67, 67, 67); font-size: 16px; line-height: 2; text-indent: 2em; font-family: -apple-system, "PingFang SC", "Helvetica Neue", STHeiti, "Microsoft Yahei", Tahoma, sans-serif; background-color: rgb(255, 255, 255);\">  They are alive, but deep down in their hearts something important has died.</p>\r\n\r\n<p style=\"padding: 10px 0px; margin: 0px; color: rgb(67, 67, 67); font-size: 16px; line-height: 2; text-indent: 2em; font-family: -apple-system, "PingFang SC", "Helvetica Neue", STHeiti, "Microsoft Yahei", Tahoma, sans-serif; background-color: rgb(255, 255, 255);\">  他們活着,但他們心中的一部分已經死了。</p>\r\n\r\n<p style=\"padding: 10px 0px; margin: 0px; color: rgb(67, 67, 67); font-size: 16px; line-height: 2; text-indent: 2em; font-family: -apple-system, "PingFang SC", "Helvetica Neue", STHeiti, "Microsoft Yahei", Tahoma, sans-serif; background-color: rgb(255, 255, 255);\">  And there are another kind of people. They choose to live with dignity.</p>\r\n\r\n<p style=\"padding: 10px 0px; margin: 0px; color: rgb(67, 67, 67); font-size: 16px; line-height: 2; text-indent: 2em; font-family: -apple-system, "PingFang SC", "Helvetica Neue", STHeiti, "Microsoft Yahei", Tahoma, sans-serif; background-color: rgb(255, 255, 255);\">  而另外一些人,他們依舊選擇有尊嚴地活着。</p>\r\n\r\n<p style=\"padding: 10px 0px; margin: 0px; color: rgb(67, 67, 67); font-size: 16px; line-height: 2; text-indent: 2em; font-family: -apple-system, "PingFang SC", "Helvetica Neue", STHeiti, "Microsoft Yahei", Tahoma, sans-serif; background-color: rgb(255, 255, 255);\">  A graceful lifestyle is not a show for others to watch. You live it because you deserve it. Through it, you are avoiding to become a victim of this cruel world.</p>\r\n\r\n<p style=\"padding: 10px 0px; margin: 0px; color: rgb(67, 67, 67); font-size: 16px; line-height: 2; text-indent: 2em; font-family: -apple-system, "PingFang SC", "Helvetica Neue", STHeiti, "Microsoft Yahei", Tahoma, sans-serif; background-color: rgb(255, 255, 255);\">  優雅的生活方式並非爲別人作的表演,而是爲了對得起本身,讓本身不會成爲無情社會摧殘下的犧牲品。</p>\r\n\r\n<p style=\"padding: 10px 0px; margin: 0px; color: rgb(67, 67, 67); font-size: 16px; line-height: 2; text-indent: 2em; font-family: -apple-system, "PingFang SC", "Helvetica Neue", STHeiti, "Microsoft Yahei", Tahoma, sans-serif; background-color: rgb(255, 255, 255);\">  This kind of people know how to find joy in simple things. They know how to make a common day safisticated and meaningful.</p>\r\n\r\n<center style=\"padding: 0px; margin: 0px; color: rgb(51, 51, 51); font-family: -apple-system, "PingFang SC", "Helvetica Neue", STHeiti, "Microsoft Yahei", Tahoma, sans-serif; font-size: 16px; background-color: rgb(255, 255, 255);\"><img alt=\"惟美圖片\" height=\"371\" src=\"https://www.yueduwen.com/uploads/allimg/1802/1-1P2032100022V.jpg\" style=\"padding: 0px; margin: 0px 0px 10px; border: none; box-shadow: rgb(174, 174, 174) 2px 3px 3px;\" width=\"600\" /></center>\r\n\r\n<p style=\"padding: 10px 0px; margin: 0px; color: rgb(67, 67, 67); font-size: 16px; line-height: 2; text-indent: 2em; font-family: -apple-system, "PingFang SC", "Helvetica Neue", STHeiti, "Microsoft Yahei", Tahoma, sans-serif; background-color: rgb(255, 255, 255);\">  他們懂得如何去發掘單純事物中的喜悅,懂得如何將平凡的時光過得精緻而充實。</p>\r\n\r\n<p style=\"padding: 10px 0px; margin: 0px; color: rgb(67, 67, 67); font-size: 16px; line-height: 2; text-indent: 2em; font-family: -apple-system, "PingFang SC", "Helvetica Neue", STHeiti, "Microsoft Yahei", Tahoma, sans-serif; background-color: rgb(255, 255, 255);\">  Life has denied them some beauty. But they build them with their own hands.</p>\r\n\r\n<p style=\"padding: 10px 0px; margin: 0px; color: rgb(67, 67, 67); font-size: 16px; line-height: 2; text-indent: 2em; font-family: -apple-system, "PingFang SC", "Helvetica Neue", STHeiti, "Microsoft Yahei", Tahoma, sans-serif; background-color: rgb(255, 255, 255);\">  那份生活中缺失的美麗,他們靠本身的雙手創造了出來。</p>\r\n\r\n<p style=\"padding: 10px 0px; margin: 0px; color: rgb(67, 67, 67); font-size: 16px; line-height: 2; text-indent: 2em; font-family: -apple-system, "PingFang SC", "Helvetica Neue", STHeiti, "Microsoft Yahei", Tahoma, sans-serif; background-color: rgb(255, 255, 255);\">  So which kind of these two are you? And which kind are you willing to be?</p>\r\n\r\n<p style=\"padding: 10px 0px; margin: 0px; color: rgb(67, 67, 67); font-size: 16px; line-height: 2; text-indent: 2em; font-family: -apple-system, "PingFang SC", "Helvetica Neue", STHeiti, "Microsoft Yahei", Tahoma, sans-serif; background-color: rgb(255, 255, 255);\">  你的人生是哪一種?你想過哪種?</p>\r\n\r\n<p style=\"padding: 10px 0px; margin: 0px; color: rgb(67, 67, 67); font-size: 16px; line-height: 2; text-indent: 2em; font-family: -apple-system, "PingFang SC", "Helvetica Neue", STHeiti, "Microsoft Yahei", Tahoma, sans-serif; background-color: rgb(255, 255, 255);\">  Have you find the answer?</p>\r\n\r\n<p style=\"padding: 10px 0px; margin: 0px; color: rgb(67, 67, 67); font-size: 16px; line-height: 2; text-indent: 2em; font-family: -apple-system, "PingFang SC", "Helvetica Neue", STHeiti, "Microsoft Yahei", Tahoma, sans-serif; background-color: rgb(255, 255, 255);\">  你找到答案了嗎?</p>\r\n</body>\r\n</html>\r\n",
  "login_advertTime": "15000",
  "login_adverClose": "1"
}, {
  "login_advertTitle": "aaaaaaa",
  "login_advertCont": "<html>\r\n<head>\r\n\t<title></title>\r\n</head>\r\n<body>asdasdasassdas d<br />\r\n<img alt=\"\" src=\"/jeecg/upload//1534303323463.jpg\" style=\"width: 250px; height: 275px;\" /><br />\r\n99999999999999</body>\r\n</html>\r\n",
  "login_advertTime": "15000",
  "login_adverClose": "1"
}];

 

var i = 0;

 

// 添加計時器
var time = setInterval(function () {
  if (i >= data.length) {
    clearInterval(time);
  } else {
    OpenAdvert(data[i].login_advertTitle, data[i].login_advertCont, data[i].login_advertTime, data[i].login_adverClose);
    i++;
  }
}, 5000);
//彈出廣告信息
function OpenAdvert(title, con, time, close) {
  layer.open({
    type: 1,
    title: title,
    fix: false,
    shadeClose: true,
    offset: 'rb',
    anim: 2,
    maxmin: true,
    area: ['1000px', '500px'],
    content: con,
    shade: 0,
    shadeClose: true,
    time: time,
    cancel: function (index, layero) {
      // 判斷是否強制關閉
      if (close == 1) {
        return true;
      } else if (close == 0) {
        return false;
      }
    }
  });
}  
相關文章
相關標籤/搜索