0

I have used below code to show a scrolling text in a content editor web part on my home page in SPO team site. [ very similar to marquee tag. We can't use marquee as W3C standards doesn't support!]

     <p><b id='banner'></b></p>
      <script>
     var newBanner=0;
     function runOnLoad(){
        var bannerImg = new Array();
            var bannerLink = new Array();
      var herelink="http://google.com";
     var linktext= "here";
         bannerImg[0]="welcome1";
     bannerImg[1]="Welcome2  Click " + 
         linktext.link('https://https://twitter.com/sundarpichai
               ') + " to know more abt Sundar";
           var totalBan = bannerImg.length;

     newBanner++;
                if (newBanner == totalBan)
                 {
                   newBanner = 0;
                  }
        document.getElementById('banner').innerHTML="<Span style
                   ='font-weight: bold; 
        font-family:arial;font-size:22pt;'>"+bannerImg[newBanner]+"</span>";
            setTimeout("runOnLoad()", 4*1000);
      }
        _spBodyOnLoadFunctionNames.push("runOnLoad");
          </script>

but i am not getting how to make this scrolling text,on a vertical manner.

Also would like to know how to read from an announcements list, if my scrolling text is dynamic.[Currently its set as Static text].

Also if there exist,any other free jQuery plugins,I can use it for scrolling text?.

1 Answer 1

2

To read from the Announcements list, you can use SharePoint API REST with JavaScript like this:

$.ajax({
    url:_spPageContextInfo.webAbsoluteUrl+"/_api/web/lists/getByTitle('Announcements')/items",
    method: "GET",
    headers: { "Accept": "application/json; odata=verbose" },
    success: function (data) {
        if (data.d.results.length > 0 ) {
            //results
        }       
    },
    error: function (data) {
        alert("Error: " + data);
    }
});

For the vertically scrolling text, you have some jQuery plugins in order to achieve that:

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.