Friday, July 4, 2014

SharePoint 2013: Use the SharePoint style sheet in an app



Add this part of code (bold) to your SharePoint 2013 code and then you can use css classes of SharePoint 2013 CSS.        

 var dclink =
               document.createElement("link");
            dclink.setAttribute("rel", "stylesheet");
            dclink.setAttribute("href", scriptbase + "defaultcss.ashx");
            var head = document.getElementsByTagName("head");
            head[0].appendChild(dclink);
 

<script type="text/javascript">
        var hostweburl;

        // Load the required SharePoint libraries.
        $(document).ready(function () {

            // Get the URI decoded URLs.
            hostweburl =
                decodeURIComponent(
                    getQueryStringParameter("SPHostUrl")
            );

            // The js files are in a URL in the form:
            // web_url/_layouts/15/resource_file
            var scriptbase = hostweburl + "/_layouts/15/";

            var dclink =
               document.createElement("link");
            dclink.setAttribute("rel", "stylesheet");
            dclink.setAttribute("href", scriptbase + "defaultcss.ashx");
            var head = document.getElementsByTagName("head");
            head[0].appendChild(dclink);

            // Load the js files and continue to
            // the execOperation function.
            $.getScript(scriptbase + "SP.Runtime.js",
                function () {
                    $.getScript(scriptbase + "SP.js", execOperation);
                }
            );
        });
</script >

  <div class="ms-core-listMenu-verticalBox ms-noList">
    <ul class="static ms-blog-listMenu-root ms-core-listMenu-root root">
        <li>
<span class="ms-core-listMenu-item ms-blog-quickLinksTitle">Authors</span>
-----------------------------------------------


 

No comments:

Post a Comment