Skip to main content
added explanation for how to add the script to a page
Source Link
Dylan Cristy
  • 12.9k
  • 3
  • 33
  • 73

Ok, so how to add this to a Wiki Page:

First, you need to link to jQuery. If you want you can link to jQuery from a CDN (like the one on the jQuery site itself), or you can upload the jQuery library to somewhere on your site (which is what I usually do).

(If you are already loading jQuery on a custom master page or something, obviously you don't have to do this as it's being loaded already.)

To upload jQuery to somewhere on your site: I usually make a "Scripts" folder inside the "Site Assets" library and put it there. Other people like using the "Style Library". It just needs to be somewhere you (and your users) have read access to so it will load for them on the Wiki Page.

Then, on the Wiki Page, put the page in edit mode and add a Script Editor Web Part at the top of the page. Select "Edit Web Part" from the web part menu and then click on "EDIT SNIPPET". In the editor window that opens, put the following code:

// if you are loading jQuery from a CDN then your src URL will be the URL to the CDN // the URL I am using here is server relative, which I prefer, or you can use one // that is relative to the "Site Pages" library where the wiki pages are, like // "../SiteAssets/Scripts/jquery-1.11.3.min.js" <script type="text/javascript" src="/sites/MySite/SiteAssets/Scripts/jquery-1.11.3.min.js"></script> <script type="text/javascript"> $(document).ready(function () { // remove those pesky zero width space unicode characters inserted by sharepoint $('.ms-rte-layoutszone-inner:contains("\u200B")').each(function () { $(this).html($(this).html().split("\u200B").join("")); }); $('.ms-rte-layoutszone-inner-editable:contains("\u200B")').each(function () { $(this).html($(this).html().split("\u200B").join("")); }); }); </script> 

Click the "Insert" button to close the script editor, "OK" to close the web part editor, and save the page. That should do it.


Ok, so how to add this to a Wiki Page:

First, you need to link to jQuery. If you want you can link to jQuery from a CDN (like the one on the jQuery site itself), or you can upload the jQuery library to somewhere on your site (which is what I usually do).

(If you are already loading jQuery on a custom master page or something, obviously you don't have to do this as it's being loaded already.)

To upload jQuery to somewhere on your site: I usually make a "Scripts" folder inside the "Site Assets" library and put it there. Other people like using the "Style Library". It just needs to be somewhere you (and your users) have read access to so it will load for them on the Wiki Page.

Then, on the Wiki Page, put the page in edit mode and add a Script Editor Web Part at the top of the page. Select "Edit Web Part" from the web part menu and then click on "EDIT SNIPPET". In the editor window that opens, put the following code:

// if you are loading jQuery from a CDN then your src URL will be the URL to the CDN // the URL I am using here is server relative, which I prefer, or you can use one // that is relative to the "Site Pages" library where the wiki pages are, like // "../SiteAssets/Scripts/jquery-1.11.3.min.js" <script type="text/javascript" src="/sites/MySite/SiteAssets/Scripts/jquery-1.11.3.min.js"></script> <script type="text/javascript"> $(document).ready(function () { // remove those pesky zero width space unicode characters inserted by sharepoint $('.ms-rte-layoutszone-inner:contains("\u200B")').each(function () { $(this).html($(this).html().split("\u200B").join("")); }); $('.ms-rte-layoutszone-inner-editable:contains("\u200B")').each(function () { $(this).html($(this).html().split("\u200B").join("")); }); }); </script> 

Click the "Insert" button to close the script editor, "OK" to close the web part editor, and save the page. That should do it.

Source Link
Dylan Cristy
  • 12.9k
  • 3
  • 33
  • 73

On one page where I was having a problem with those, I added a little script to remove them automagically:

$(document).ready(function () { // remove those pesky zero width space unicode characters inserted by sharepoint $('.ms-rte-layoutszone-inner:contains("\u200B")').each(function () { $(this).html($(this).html().split("\u200B").join("")); }); $('.ms-rte-layoutszone-inner-editable:contains("\u200B")').each(function () { $(this).html($(this).html().split("\u200B").join("")); }); });