New Benefits RSS

Implementation: Javascript Method

By referencing a few scripts, benefit content can be pulled onto your website without having active server pages. This content will inherit css page styling, or you can add inline styling to the containing element.

  1. Add script references to the HEAD tag of your page:

    <script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
    <script src="https://cdn.newbenefits.com/contentJS/contentLoader.js"></script>
  2. Add an id to a container element, like a div, span, etc. Each seperate container element must be named uniquely and cannot be nested. For example:

    <span id="rss" style="border: solid 2px red; display: block"></span>
    <div id="rssDiv2" style="border: solid 2px blue;"></div>
  3. Add the following section before the </BODY> tag:

    <script>
    $(document).ready(() => {

        var rss = new NB_Content();
        rss.htmlElementID = "rss";
        rss.hash = "mF32gJrBQZIqHePjWTBxQ";
        rss.AddSection("Test Feed");
        rss.Load();

    });
    </script>

    Replace the hash with the benefit hash for the sections you're pulling from content.newbenefits.com.
    The element ID's called by the script must match the corresponding container element above.

    Multiple AddSection snippets can be added to pull multiple sections of the same benefit feed:

    <script>
    $(document).ready(() => {

        var rss = new NB_Content();
        rss.htmlElementID = "rss";
        rss.hash = "mF32gJrBQZIqHePjWTBxQ";
        rss.AddSection("Test Feed");
        rss.AddSection("Part 2");
        rss.Load();

    });
    </script>
  4. If you have multiple pulled sections on your page(container elements), multiple script snippets must be used, each with their container element referenced:

    <script>
    $(document).ready(() => {

        var rss = new NB_Content();
        rss.htmlElementID = "rss";
        rss.hash = "mF32gJrBQZIqHePjWTBxQ";
        rss.AddSection("Test Feed");
        rss.Load();

        var rssDiv2 = new NB_Content();
        rssDiv2.htmlElementID = "rssDiv2";
        rssDiv2.hash = "mF32gJrBQZIqHePjWTBxQ";
        rssDiv2.AddSection("Part 2");
        rssDiv2.Load();
    });
    </script>

Note: One of the drawbacks to this method is that it requires that visitors have scripts enabled in order to view benefit content.

Have Questions?

Contact us today to get started.

Contact Us


Contact Information

Phone: 800.800.8304
972.404.8192
Fax: 972.991.5218
Email: info@newbenefits.com

New Benefits, Health & Medical - General, Dallas, TX