I have an HTML file with javascript and CSS inside, and I want to link all of the web parts on my web part page to that HTML file so that they are all affected by it. How do I do this? I see people suggest a content link through a content editor, but you can't add web parts to a content editor so I don't see how that is useful.


  • I have a web part page.
  • There are web parts in the web part page.
  • I want to refer these web parts to some javascript and css that I have in a local HTML file.
  • I can upload the HTML file to my Sharepoint website if necessary.
  • I can not use a script editor to achieve what I want because google chrome throws an XSS auditor error whenever any javascript is added to a page through a script editor. The error is thrown when the script editor contains any javascript and I try to edit the page.
  • I see people suggesting content editors and using the content link property of the content editors to link to the HTML file (I've seen it in other similar questions), but you cannot add web parts to a content editor so I do not see how it applies.
  • Where is the HTML page hosted? What do you want to be able to do with the imported HTML page - you mention you want to add javascript to it? When people suggested "content link", I think they suggested setting the content link property of a contend editor webpart. Jun 12, 2017 at 12:51
  • The HTML file is local. I can upload it to Site Assets or some place else on my Sharepoint site. The HTML file already has javascript in it. I want to apply the javascript and css that are in the HTML file to the web parts in one of my web part pages. I know what they were suggesting when they talked about content link, and I explained why it doesn't apply.
    – Mdomin45
    Jun 12, 2017 at 12:56
  • The answer is probably still to use a "content editor webpart" and set its Content link property. You clearly mention that you are able to add other webparts so I'm not sure why would not be able to add that one? Also, the XSS errors from Chrome is probably because you are hosting the file on another domain (XSS = Chross Site Scripting). If you host the HTML and JS in your SP site it will probably not occur. Jun 12, 2017 at 13:43
  • The XSS error has nothing to do with where the I am hosting the file. I type the raw code into a script editor and it throws the error. This happens to anyone who uses Sharepoint 2013 and adds javascript to a script editor web part. I can add any web part - that isn't the problem. The problem is that the content link property of a content editor can only affect the content editor. I need the HTML file to affect all of the web parts on the page.
    – Mdomin45
    Jun 12, 2017 at 13:46
  • I am somewhat unclear on the details of the question. Are you wanting to affect OTB SharePoint web parts that you have added to a web part page? Or... are you wanting to affect web parts that you have created via a content editor web part that includes an HTML file?
    – maleman
    Jun 12, 2017 at 14:13

1 Answer 1


Some options:

  • Create a custom webpart which loads the HTML via some API (e.g. WebClient, SharePoint's SPFile.OpenBinaryStream(), etc depending on where the page is hosted) and add the content to the page (Response.Write, or add it to value of LiteralControl)
  • Disable XSS Auditor by setting HTTP headers - https://www.virtuesecurity.com/blog/understanding-xss-auditor/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.