locked
Strange Javascript issue in masterpage RRS feed

  • Question

  • People started to report that they couldn't add WEB PARTS anymore and some other problems like "no user name appeard" when writing the user login and clicking in the check incon. And some other problems.

    Every test was done in IE 10.

    As this seemed to be a javascript issue I found aout that removing the event handler in the BODY tag:

    <body scroll="no" onload="if (typeof(_spBodyOnLoadWrapper) != 'undefined') _spBodyOnLoadWrapper();" class="v4master">

    changed to this:

    <body scroll="no" class="v4master">

    And everything seemed to started working again.

    The problem is that we have more that 7 hundred sites and subsites and I would have to change each masterpage for that to work. Also I need to know why that started happening out of nowhere. And if there will be side effects of removing the event handler.

    I figured that the code comes from

    INIT.js in

    Web Server Extensions\14\TEMPLATE\LAYOUTS\1046

    and

    Web Server Extensions\14\TEMPLATE\LAYOUTS\1033

    and there is also a INIT.debug.js

    I found out the INIT.JS file was modified by someone (we have a problem here that to many people have access to the server)

    I restored INIT.JS and INIT.DEBUG.JS in both directories from a QA enviornment where it works

    But the problem persists. It seems the restore didn't have effect. I cleaned my ie temporary files but still no success.

    The only workaround we have so far is to remove the onload event handler.

     How can I fix that in all 7 hundred master pages at once? Is it possible?

    How can I restore SharePoint JavaScript original files?

    Thanks

    Questions


    L. Skynyrd




    • Edited by J.Clua Friday, October 11, 2013 2:34 PM
    Friday, October 11, 2013 2:31 PM

Answers

  • You could install a copy of SharePoint using the binaries and patch it to the relevant level, then replace the Javascript files on all your servers. It's not an ideal approach but if someone's been playing cowboy with your JS then it might be a nessicary evil.
    SharePoint service packs aren't automatically listed in event viewer. This blog shows you how to confirm the build number you are using, the PowerShell approach is the most robust:
    http://www.bradleyschacht.com/check-version-of-sharepoint-2010-currently-installed/
    • Proposed as answer by Steven AndrewsEditor Monday, October 14, 2013 9:57 PM
    • Marked as answer by J.Clua Tuesday, October 15, 2013 4:42 PM
    Monday, October 14, 2013 12:05 PM

All replies

  • Well there's a few things in there.

    The Javascript files are cached by users when they first user them. To force an update you can do a Control + F5, check if that brings in the correct javascript file.

    You can use PowerShell to loop through all the Site Collections or Sub Sites and modify the master page.

    This script describes how to set the master page: http://get-spscripts.com/2010/09/changing-master-page-on-sharepoint.html

    This process should allow you to upload the master page, although i haven't testd it: http://www.sharepointexcellence.com/2012/05/upload-master-pages-page-layouts-to.html

    Friday, October 11, 2013 6:34 PM
  • Thanks for your suggestions.

    - I did clean my IE temporary cash before doing each test.

    - I can't set all masterpages to the same because each site can be different from each other.

    But anyway thanks for the info about that. It's already in my favorit links.

    That would be working around the consequences of the problem and I would rather find out the cause of the problem.

    All sites started throwing javascript erros and there must be a reason for that.

    The only 2 possible explanations that I came up with are:

    - A Service Pack or update that impacted Shapoint's javascript execution plan: (http://www.toddklindt.com/blog/Lists/Posts/Post.aspx?ID=430 ).

    But it's not the case because we checked the server event log and there is no trace of any install on the server.

    - Someone deplyed something or changed something that impacted the whole farm.

    Is there a way to restore all Sharepoint core javascript files like init.js for example?

    I undestand they shouldn't be changed.

    Thank you very much for your help

     

     

     


    L. Skynyrd

    Monday, October 14, 2013 11:33 AM
  • You could install a copy of SharePoint using the binaries and patch it to the relevant level, then replace the Javascript files on all your servers. It's not an ideal approach but if someone's been playing cowboy with your JS then it might be a nessicary evil.
    SharePoint service packs aren't automatically listed in event viewer. This blog shows you how to confirm the build number you are using, the PowerShell approach is the most robust:
    http://www.bradleyschacht.com/check-version-of-sharepoint-2010-currently-installed/
    • Proposed as answer by Steven AndrewsEditor Monday, October 14, 2013 9:57 PM
    • Marked as answer by J.Clua Tuesday, October 15, 2013 4:42 PM
    Monday, October 14, 2013 12:05 PM
  • Got it.

    Someone changed INIT.JS in the WFE to use a feature named CARDIOLOG:

    http://support.intlock.com/entries/21850987-Tracking-Agent-Configuration

    The problem was that he forgot to activate the feature in the server.

    I removed the custumized INIT.JS and put the original version back on and everything changed to normal after a Ctrl + F5.

    I don't think is a good practice to use SharePoint core js files.

    Thanks!


    L. Skynyrd

    Tuesday, October 15, 2013 4:45 PM
  • It really isn't, from memory any changes to the files in the hive are explicitly unsupported. Thanks for the update.
    Tuesday, October 15, 2013 5:30 PM