I'm using PIE.js to force IE7 to use CSS3 styles. However, whenever an element on my SharePoint page contains the class that PIE is supposed to style, it actually inserts the code into the html when rendered. Then upon editing the page, the code is added again on top of the old code. So at first I start with a simple tag with a class, then I end up with 200+ lines of code.

The question: How can I prevent SharePoint from literally writing the rendered code from the javascript?

I know this is a larger issue than just PIE.js...any javascript append or prepend actually prints the code in SharePoint.

3 Answers 3


The root of the problem is that PIE.js is rewriting Html within the content itself when the page is being edited and the simplest fix for it is to not include PIE.JS if the page is being edited.

How you do this depends entirely on your environment and comfort level. There are Javascript methods to determine if the page is being edited, page layout/master page methods and code methods where you can conditionally register the script include, like Abe suggested.

  • 1
    Excellent! This lead to the answer. I also had to be sure that my css wasn't attempting to style the element while in "design" mode. The css styles have a "behavior" attribute that calls the PIE.js file which will cause the problems. I added the styled classes via javascript which was only running during "browse" mode.
    – Barry
    Jul 18, 2012 at 18:43

If you want Javascript to only run once you could always do a.... (This will make sure it only runs once even if the JavaScript is contained in multiple files)

var myObj = myObj || {};

$(document).ready(function () {
    if (!(myObj.token)) {
        // Code goes here
        myObj.token = {};  // this ensure we won't enter the if block the next time

Why this is happening really depends on how you are adding the script. In the past I have used RegisterClientScriptInclude to add a script once. In order for this to work you need to include the same script with the same key everywhere. This way it will not be added if the script is already on the page. Example:

Page.ClientScript.RegisterClientScriptInclude("MultiPartJS", "/_layouts/MNCAssets/Scripts/multiPart.min.js");

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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