0

I am using SharePoint 2010 and I need to place the following JavaScript code on a page to give me time in Rome

<SCRIPT LANGUAGE="JavaScript">

  function GetTime() {
  var dt = new Date();
  var def = dt.getTimezoneOffset()/60;
  var gmt = (dt.getHours() + def);

  var ending = ":" + IfZero(dt.getMinutes());
  var rome =check24(((gmt + 5) > 24) ? ((gmt + 5) - 24) : (gmt + 5));

  document.getElementById("LocalTime2").innerHTML = (IfZero(rome) + ending);
  setTimeout("GetTime()", 1000);
  }
  function IfZero(num) {
    return ((num <= 9) ? ("0" + num) : num);
  }
  function check24(hour) {
    return (hour >= 24) ? hour - 24 : hour;
  }
  //  End -->
  window.onload = GetTime;

 </script>

 <span id="LocalTime2"></span>

Currently I placed it in a CEWP and it does work, but then when I click save my drop down navigations from the menu stop working and I cant edit the page again.

Getting the following error message:

Message: 'SP.Ribbon.PageState.ImportedNativeData.PageState' is null or not an object Line: 2 Char: 79472 Code: 0 URI: http://cpts1-spointdev/_layouts/sp.ribbon.js?rev=F%2BUEJ66rbXzSvpf7nN69wQ%3D%3D

Any idea why this is happening?

Any other work-around that I can try?

1 Answer 1

0

Instead of your window.onload try this

_spBodyOnLoadFunctionNames.push("GetTime");

Hope this helps

1
  • Glad it worked! :) Commented Feb 10, 2011 at 14:10

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.