Why is “​” being injected into my HTML?

后端 未结 8 1679

EDIT: You can see the issue here (look in source).

EDIT2: Interesting, it is not an issue in source. Only with the console (Firebug as well).

I have

8条回答
  •  南方客
    南方客 (楼主)
    2020-11-29 05:03

    I understand that there is a bug in SharePoint 2013 where the HTML editor adds these characters into your content.

    I've been dealing with this for a bit and this is the solution I am using which seems to be working. I added this javascript into a file referenced by my masterpage.

    var elements = ["h1","h2","h3","h4","p","strong","label","span","a"];
    function targetZWS(){
        for (var i = 0; i < elements.length; i++) {
          jQuery(elements[i]).each(function() {
            removeZWS(this);
          });
        }
    }
    function removeZWS(target) {
      jQuery(target).html(jQuery(target).html().replace(/\u200B/g,''));
    }
    
    /*load functions*/
    $(document).ready(function() {
        _spBodyOnLoadFunctionNames.push("targetZWS");
    
    });
    

    Links I looked into investigating this:

    1. https://social.msdn.microsoft.com/Forums/sharepoint/en-US/23804eed-8f00-4b07-bc63-7662311a35a4/why-does-sharepoint-put-in-character-code-8203-in-a-richtext-field?forum=sharepointdevelopment

    2. https://social.technet.microsoft.com/Forums/office/en-US/e87a82f0-1ab5-4aa7-bb7f-27403a7f46de/finding-8203-unicode-characters-in-my-source-code?forum=sharepointgeneral

    3. http://www.sharepointpals.com/post/Removing-8203-in-RichTextHTML-field-Sharepoint

提交回复
热议问题