0

所以,这就是我到目前为止所拥有的。我收到了缩短帖子的请求,以便立即显示更多帖子。我需要找到一种方法将内容文本限制为一个段落。有没有可以做到这一点的帖子字符串?预先感谢您的考虑。

    var feed1 = new google.feeds.Feed("http://example1/atom.xml");
    feed1.load(function(result) {
      if (!result.error) {
        var container = document.getElementById("feed1");
        var postString = "";
        for (var i = 0; i < 1; i++) {
          var entry = result.feed.entries[i];
          var attributes = ["title", "link", "publishedDate", "content"];
            var div = document.createElement("div");
            var linkText = entry[attributes[1]];
            var titleText = entry[attributes[0]];
            var dateText =  entry[attributes[2]];
            dateText = dateText.substring(0,16);
            var contentText = entry[attributes[3]];
            postString += "<h2><a href='";
            postString += linkText;
            postString += "'>"
            postString += titleText;
            postString += "</a></h2><p>";
            postString += contentText;
            postString += "<a href='";
            postString += linkText;
            postString += "' class='view-more'>read more</a>";
            postString += "</p>";
            container.innerHTML = postString;
        }
      }

    });
4

0 回答 0