A user has added some custom JS code into a web-page, making it unusable.

Basically the ribbon cannot be opened, and web-parts cannot be modified.

Custom JS:

<script type="text/javascript">
tday=new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday");
tmonth=new Array("January","February","March","April","May","June","July","August","September","October","November","December");

function GetClock(){
var d=new Date();
var nday=d.getDay(),nmonth=d.getMonth(),ndate=d.getDate(),nyear=d.getYear();
if(nyear<1000) nyear+=1900;
var nhour=d.getHours(),nmin=d.getMinutes(),nsec=d.getSeconds(),ap;

if(nhour==0){ap=" AM";nhour=12;}
else if(nhour<12){ap=" AM";}
else if(nhour==12){ap=" PM";}
else if(nhour>12){ap=" PM";nhour-=12;}

if(nmin<=9) nmin="0"+nmin;
if(nsec<=9) nsec="0"+nsec;

document.getElementById('clockbox').innerHTML=""+tday[nday]+", "+tmonth[nmonth]+" "+ndate+", "+nyear+" "+nhour+":"+nmin+":"+nsec+ap+"";

<div id="clockbox"></div>

The below are the errors I am getting through the browsers' debuggers:


Chrome- Debugger


Firefox Debugger


IE Debugger

Web-Part athat was added (Content Editor with custom JS)

Web Part giving error

If I click any of the tabs 'Browse|Page|Publish' on the ribbon nothing happens and no errors are show in IE.

If I append ?ControlMode=Edit to the end of the page's URL, in IE it will open in Edit mode but on other browsers it won't work.

Although it opens in IE, I still cannot modify web-parts. If I press the web-part's arrow in IE, nothing happens.

Could this be Javascript related? Maybe I need to link to it differently from the Master Page, or maybe some missing code in the page itself?


Emulated IE6 - error:

SCRIPT5007: Unable to get property 'clientWidth' of undefined or null reference

Warning (in all versions):

SEC7115: :visited and :link styles can only differ by color. Some styles were not applied to :visited.


Added a link to Core.js in MasterPage. Accessed page in 'Edit' mode by appending ?DisplayMode=Design&ControlMode=Edit# to the URL.

enter image description here

2 Answers 2


The custom JS is most probably causing issues, it may be using same name of variables. I would open the page in webpart maintenance mode and delete\disable that web part. To open in webpart maintenance you need to append the url of the page with {yourUrl}?contents=1

REf: https://support.office.com/en-us/article/Open-and-use-the-Web-Part-Maintenance-Page-eff9ce22-d04a-44dd-ae83-ac29a5e396c2?ui=en-US&rs=en-US&ad=US&fromAR=1

  • Unfortunately I cannot access the page you told me. I can only add web-parts but I cannot add anything to them by appending ?DisplayMode=Design&ControlMode=Edit# to the URL. I cannot even delete as when I click on the web-part I get a number of errors. Kindly review updated question.
    – Brian
    Commented Jul 1, 2016 at 9:13
  • sorry misspelled it should be ?contents=1, and that would be without the '?Design(...) so the url should be mainurl/sites/siteA/SitePages/PageA.aspx?contents=1 Commented Jul 1, 2016 at 9:23

This certainly seems to be a Browser related issue. which version of IE are you using? Try changing the IE to different versions from developer tool and check if you still encounter the error. Also try loading the page in Chrome. There is some javascript object which seems to be deprecated in current version of browser.

  • I am using IE11 but if it was an IE issue it would work on Chrome and Firefox no?
    – Brian
    Commented Jul 1, 2016 at 8:09
  • objects supported in IE 11 is supported in chrome and firefox browser as well. Change the version of IE and then load the page. check if still it exists Commented Jul 1, 2016 at 8:12
  • I have emulated up till version 6 of IE. Kindly review updated question.
    – Brian
    Commented Jul 1, 2016 at 8:21
  • if you are getting a null error for resources..why dont you put a null check for resources in the custom js file added? Commented Jul 1, 2016 at 9:18
  • I can't modify the web-part. I get JS errors when trying to modify the web-part's settings.
    – Brian
    Commented Jul 1, 2016 at 9:25

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.