How to add Javascript and CSS in page layout with SharePoint 2013

Source: Internet
Author: User

How to add Javascript and CSS in page layout with SharePoint 2013

Sometimes, we need create a custom page layout, at the time, if we want to add some JavaScript and CSS code, what do it? We cannot add the code in page layout file directly, the Syetem would filter it and the code lost function. Follow my steps to resolve it.

1. Open the page layout file, it is HTML file2. You must add the JavaScript and CSS under the label <!--ms:<asp:contentplaceholder id= "Placeholderadditionalpagehea D "runat=" Server "&GT;--&GT;. Find the label
  <!--ms:<asp:contentplaceholder id= "Placeholderadditionalpagehead" runat= "Server" >-->   <!--ME: </asp:ContentPlaceHolder>-->
3. You need handle your CSS label when add CSS label, or the CSS would be a filter, the correct CSS label is:
<!--ms:<style type= "text/css" >-->//Add your CSS code<!--ME: </style>-->
4. Add JavaScript code, but you need focus on the Document.ready, the Document.ready would lost function for page layout is Heriting from master page, so the body loading is difference. You must use the function named "_spbodyonloadfunctionnames.push"
<script>  _spbodyonloadfunctionnames.push ("cutomfunction"); function cutomfunction () {//...} </script>



How to add Javascript and CSS in page layout with SharePoint 2013

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.