locked
Script in CEWP disables Top-Link Bar? RRS feed

  • Question

  • I am using a CEWP to display an HTML scripted world clock on our SharePoint 2007 portal site.  The clock works perfectly, but for some reason it disables the toplink bar on any page it is being used.  The toplink bar is visible, but when you hover over it, it does nothing?  Does anyone know why this would happen?  I can supply the script to help locate the problem.

     

    Thank you,

     

    Scott


    • Edited by Mike Walsh FIN Saturday, May 7, 2011 5:32 AM just "our SharePoint 2007 portal site" is enough. We don't need to know what "business" you are in.
    Wednesday, May 4, 2011 4:35 PM

Answers

  • Hey Scott... I'm sure someone smarter than me knows why, but the flyout on the TopLink Nav is breaking because of "window.onload=InitWorldClock;". I can only assume that you are overwriting what SharePoint wants to do on window.onload?

    You can get around this with the code below. I just removed the "window.onload" and called the "InitWorldClock();" directly at the end of the script and all was right with the world.

    Hope it works for you as well... Sorry it too so long to get the answer for you,
    Mark 

          <script language="JavaScript">
          
          var Regions = Array();
          var UTCTime = new Date().getUTCMilliseconds();
          var monthArray = new Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December")
          var gmt = new Date()
          var gmtMilisecondsOffset = gmt.getTimezoneOffset() * 60 * 1000;      
          
          function WorldClockRegion(name, title, offset, SpringDTSMonth, SpringDTSWeekDate, SpringDTSWeekDateOrderNumber, SpringDTSHours, SpringDTSMinutes, FallDTSMonth, FallDTSWeekDate, FallDTSWeekDateOrderNumber, FallDTSHours, FallDTSMinutes){
            this.RegionName = name;
            this.RegionTitle = title;
            this.RegionTimeOffset = offset;
            
            this.SpringDTSMonth = SpringDTSMonth;
            this.SpringDTSWeekDate = SpringDTSWeekDate;
            this.SpringDTSWeekDateOrderNumber = SpringDTSWeekDateOrderNumber;
            this.SpringDTSHours = SpringDTSHours;
            this.SpringDTSMinutes = SpringDTSMinutes;
            
            this.FallDTSMonth = FallDTSMonth;
            this.FallDTSWeekDate = FallDTSWeekDate;
            this.FallDTSWeekDateOrderNumber = FallDTSWeekDateOrderNumber;
            this.FallDTSHours = FallDTSHours;
            this.FallDTSMinutes = FallDTSMinutes;
            this.DST = "";
          }
          
          function InitWorldClockRegions(){
            var index = 0;
    Regions[index++] = new WorldClockRegion("Hawaii","MDSU ONE",-10);
    Regions[index++] = new WorldClockRegion("Pacific","COMEODGRU ONE",-8, 2,0,2,2,0, 9,0,2,0,0); // months and weekdays starts from 0 - SUN
    Regions[index++] = new WorldClockRegion("Atlantic","COMEODGRU TWO",-5, 2,0,2,2,0, 9,0,2,0,0);
    Regions[index++] = new WorldClockRegion("ZULU","(GMT)",0);   // zulu looks like corrected already     
    Regions[index++] = new WorldClockRegion("Italy","EODMU EIGHT",1, 2,0,"LAST",2,0, 9,0,"LAST",3,0);
    Regions[index++] = new WorldClockRegion("Iraq","(OIF)",3);
    Regions[index++] = new WorldClockRegion("Afghanistan","(OEF)",4.5);
    Regions[index++] = new WorldClockRegion("Guam","EODMU FIVE",10);        
        
            
            
            
            
            
            
          }
          function InitDTS(){
            for(var i =0; i < Regions.length;i++){
              if(Regions[i].SpringDTSMonth != null && Regions[i].SpringDTSWeekDate != null && Regions[i].SpringDTSWeekDateOrderNumber != null){
                var springDD = getMonthWeekOrderDay(Regions[i].SpringDTSMonth, Regions[i].SpringDTSWeekDate, Regions[i].SpringDTSWeekDateOrderNumber);
                var fallDD = getMonthWeekOrderDay(Regions[i].SpringDTSMonth, Regions[i].SpringDTSWeekDate, Regions[i].SpringDTSWeekDateOrderNumber);
                
                springDD.setHours(Regions[i].SpringDTSHours);
                springDD.setMinutes(Regions[i].SpringDTSMinutes);
                
                var today = new Date();
                if(springDD.getTime() < today.getTime()){
                  Regions[i].RegionTimeOffset++;
                  Regions[i].DST = "DST";
                }
              }
              if(Regions[i].FallDTSMonth != null && Regions[i].FallDTSWeekDate != null && Regions[i].FallDTSWeekDateOrderNumber != null){
     
                var fallDD = getMonthWeekOrderDay(Regions[i].FallDTSMonth, Regions[i].FallDTSWeekDate, Regions[i].FallDTSWeekDateOrderNumber);
                fallDD.setHours(Regions[i].FallDTSHours);
                fallDD.setMinutes(Regions[i].FallDTSMinutes);
                
                var today = new Date();
                if(fallDD.getTime() < today.getTime()){
                  Regions[i].RegionTimeOffset--;
                  Regions[i].DST = "";
                }
              }                    
            }
          }
          function getTotalDaysInMonth(month){
            var TotalDaysInMonth = 31;
            if(month == 1)
              TotalDaysInMonth = 29;
              
            var d = new Date();
            d.setMonth(month);
            d.setDate(TotalDaysInMonth);
            var check_month = d.getMonth();
            if(month != check_month){
              if(month == 1)
                TotalDaysInMonth = 28;
              else
                TotalDaysInMonth = 30;
            }
            return TotalDaysInMonth;
          }
          function getMonthWeekOrderDay(month, WeekDay, Order){
            var mwkd = getMonthWeekDays(month, WeekDay);
            if(Order == "LAST")
              return mwkd[mwkd.length-1];
            return mwkd[Order-1];
          }      
          function getMonthWeekDays(month, WeekDay){
          
            var TotalDaysInMonth = getTotalDaysInMonth(month);
            var aWeekDays = Array();
            
            for(var i=1; i <= TotalDaysInMonth; i++){
              var dd = new Date();
              dd.setMonth(month);
              dd.setDate(i);
              if(WeekDay == dd.getDay()){
                aWeekDays[aWeekDays.length] = dd;
              }
            }        
            return aWeekDays;
          }
          
          function RenderWorldClockRegionsPlaceholders(){
            var output = '<table>';
            
            var tr1 = '<tr class="hrow">';
            var tr2 = '<tr>';
            for(i=0; i < Regions.length; i++){
          
              tr1 += "<td class=regionHeader><CENTER>"+Regions[i].RegionName+"<br><center>"+Regions[i].RegionTitle+"</td>";                          
              tr2 += "<td><center><span id="+Regions[i].RegionName+" class=></span></td>";
                                                
            }
            tr1 += '</tr>';
            tr2 += '<tr>';
            output += tr1 + tr2 +'</table>';
    
            document.getElementById("WorldClock").innerHTML = output;
          }
          function SetWorldClockTime(){
            
            for(i=0; i < Regions.length; i++){
              regionTime = new Date();
       
              regionTime = regionTime.getTime() + (gmtMilisecondsOffset + (Regions[i].RegionTimeOffset * 60 * 60 * 1000));
              regionTime = new Date(regionTime);
              
              var hr = regionTime.getHours();
              hr = CorrectTime(hr);
              
              var min = regionTime.getMinutes();
              min = CorrectTime(min);
              
              var sec = regionTime.getSeconds();
              sec = CorrectTime(sec);
              
              var currentTime = new Date();
              var boldBegin = "<span class=otherRegion>";
              var boldEnd = "</span>";
              
             // window.alert((currentTime.getTime() - regionTime.getTime()))
             var dif = (currentTime.getTime() - regionTime.getTime());
              if(dif > -10000 && dif < 10000){
                boldBegin = "<span class=currentRegion>";
                boldEnd = "</span>";
              }
              
              var time = boldBegin + regionTime.toDateString() + "<br>" + hr + ":" + min + ":" + sec + " " + Regions[i].DST + boldEnd;
              
              document.getElementById(Regions[i].RegionName).innerHTML = time;
            }
            
            setTimeout("SetWorldClockTime()", 1000)
          }
          function CorrectTime(t){
            if(t < 10)
              return "0" + t;
            return t;
          }
          function InitWorldClock(){
            InitWorldClockRegions();
            InitDTS();
            RenderWorldClockRegionsPlaceholders();
            SetWorldClockTime();
          }
    
          
    
    
          </script>
    <style type="text/css">
    .hrow {
    font-weight:bold;
    font-family:courier new;
    font-size:12px;
    color: #000000;
    }
    .hrow td{
    4padding: 10px;
    width: 125px;
    }
    .hrow td{
    text-align:center;
    }
    .currentRegion{
    font-weight:bold;
    color: navy;
    font-family:courier new;
    font-size:12px;
    }
    .otherRegion{
    font-weight:normal;
    color: navy;
    font-family:courier new;
    font-size:12px;
    }
    .regionHeader{
      background-color:#CAE1FF;
    }
    </style>      
    
    <div id="WorldClock"></div>
     <script language="JavaScript">
     InitWorldClock();
     </script>
    

    • Marked as answer by Danger Powers Wednesday, May 11, 2011 11:39 PM
    Wednesday, May 11, 2011 9:10 PM

All replies

  • Hi Scott,

    did you check the same behavior for different browsers ?

    If it works in other browser then enable scripting and active X components in IE and then try to preform the action.

    hth


    Warm Regards, Pratik Vyas | SharePoint Consultant | http://sharepointpratik.blogspot.com/
    Wednesday, May 4, 2011 5:30 PM
  • Sounds like the script for the clock MAY be using the same element id as something else on the page (or something similar).  If you could supply the script we may be able to spot something fairly quickly.

    Good luck!

    Mark

    Wednesday, May 4, 2011 5:59 PM
  • Hi Pratik,

    Unfortunately we are on a military network so we can only use IE8.  I have logged in from home before and had the same results. Active X and scripting is enabled.  I have used a basic clock script on the page and it works fine and does not disable the TopLink bar.  The reason we switched to the new script was that due to user requests for a more functional world clock.

    Thank you,

    Scott

     

     

    Wednesday, May 4, 2011 6:11 PM
  • Hi Mark,

     

    Yes I can send the script, how do I upload it to the forum? 

    Thank you for your help!

    Scott

    Wednesday, May 4, 2011 6:13 PM
  • You don't upload it.

    You either have it as text in a post here (usual if not too long)

    Or you put it on a anonymously accessible INet site and post the URL to that page here.

    Moderator


    SP 2010 "FAQ" (mainly useful links): http://wssv4faq.mindsharp.com/default.aspx
    WSS3/MOSS FAQ (FAQ and Links) http://wssv3faq.mindsharp.com/default.aspx
    Both also have links to extensive book lists and to (free) on-line chapters
    Wednesday, May 4, 2011 6:33 PM
  • Mark,

     

    Here is the script I am using:

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 TRANSITIONAL//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>

     <head>
      <title></title>
                <script language="JavaScript">
               
                var Regions = Array();
                var UTCTime = new Date().getUTCMilliseconds();
                var monthArray = new Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December")
                var gmt = new Date()
                var gmtMilisecondsOffset = gmt.getTimezoneOffset() * 60 * 1000;           
               
                function WorldClockRegion(name, title, offset, SpringDTSMonth, SpringDTSWeekDate, SpringDTSWeekDateOrderNumber, SpringDTSHours, SpringDTSMinutes, FallDTSMonth, FallDTSWeekDate, FallDTSWeekDateOrderNumber, FallDTSHours, FallDTSMinutes){
                    this.RegionName = name;
                    this.RegionTitle = title;
                    this.RegionTimeOffset = offset;
                   
                    this.SpringDTSMonth = SpringDTSMonth;
                    this.SpringDTSWeekDate = SpringDTSWeekDate;
                    this.SpringDTSWeekDateOrderNumber = SpringDTSWeekDateOrderNumber;
                    this.SpringDTSHours = SpringDTSHours;
                    this.SpringDTSMinutes = SpringDTSMinutes;
                   
                    this.FallDTSMonth = FallDTSMonth;
                    this.FallDTSWeekDate = FallDTSWeekDate;
                    this.FallDTSWeekDateOrderNumber = FallDTSWeekDateOrderNumber;
                    this.FallDTSHours = FallDTSHours;
                    this.FallDTSMinutes = FallDTSMinutes;
                    this.DST = "";
                }
               
                function InitWorldClockRegions(){
                    var index = 0;
    Regions[index++] = new WorldClockRegion("Hawaii","MDSU ONE",-10);
    Regions[index++] = new WorldClockRegion("Pacific","COMEODGRU ONE",-8, 2,0,2,2,0, 9,0,2,0,0); // months and weekdays starts from 0 - SUN
    Regions[index++] = new WorldClockRegion("Atlantic","COMEODGRU TWO",-5, 2,0,2,2,0, 9,0,2,0,0);
    Regions[index++] = new WorldClockRegion("ZULU","(GMT)",0);      // zulu looks like corrected already         
    Regions[index++] = new WorldClockRegion("Italy","EODMU EIGHT",1, 2,0,"LAST",2,0, 9,0,"LAST",3,0);
    Regions[index++] = new WorldClockRegion("Iraq","(OIF)",3);
    Regions[index++] = new WorldClockRegion("Afghanistan","(OEF)",4.5);
    Regions[index++] = new WorldClockRegion("Guam","EODMU FIVE",10);               
           
                   
                   
                   
                   
                   
                   
                }
                function InitDTS(){
                    for(var i =0; i < Regions.length;i++){
                        if(Regions[i].SpringDTSMonth != null && Regions[i].SpringDTSWeekDate != null && Regions[i].SpringDTSWeekDateOrderNumber != null){
                            var springDD = getMonthWeekOrderDay(Regions[i].SpringDTSMonth, Regions[i].SpringDTSWeekDate, Regions[i].SpringDTSWeekDateOrderNumber);
                            var fallDD = getMonthWeekOrderDay(Regions[i].SpringDTSMonth, Regions[i].SpringDTSWeekDate, Regions[i].SpringDTSWeekDateOrderNumber);
                           
                            springDD.setHours(Regions[i].SpringDTSHours);
                            springDD.setMinutes(Regions[i].SpringDTSMinutes);
                           
                            var today = new Date();
                            if(springDD.getTime() < today.getTime()){
                                Regions[i].RegionTimeOffset++;
                                Regions[i].DST = "DST";
                            }
                        }
                        if(Regions[i].FallDTSMonth != null && Regions[i].FallDTSWeekDate != null && Regions[i].FallDTSWeekDateOrderNumber != null){
     
                            var fallDD = getMonthWeekOrderDay(Regions[i].FallDTSMonth, Regions[i].FallDTSWeekDate, Regions[i].FallDTSWeekDateOrderNumber);
                            fallDD.setHours(Regions[i].FallDTSHours);
                            fallDD.setMinutes(Regions[i].FallDTSMinutes);
                           
                            var today = new Date();
                            if(fallDD.getTime() < today.getTime()){
                                Regions[i].RegionTimeOffset--;
                                Regions[i].DST = "";
                            }
                        }                                       
                    }
                }
                function getTotalDaysInMonth(month){
                    var TotalDaysInMonth = 31;
                    if(month == 1)
                        TotalDaysInMonth = 29;
                       
                    var d = new Date();
                    d.setMonth(month);
                    d.setDate(TotalDaysInMonth);
                    var check_month = d.getMonth();
                    if(month != check_month){
                        if(month == 1)
                            TotalDaysInMonth = 28;
                        else
                            TotalDaysInMonth = 30;
                    }
                    return TotalDaysInMonth;
                }
                function getMonthWeekOrderDay(month, WeekDay, Order){
                    var mwkd = getMonthWeekDays(month, WeekDay);
                    if(Order == "LAST")
                        return mwkd[mwkd.length-1];
                    return mwkd[Order-1];
                }           
                function getMonthWeekDays(month, WeekDay){
               
                    var TotalDaysInMonth = getTotalDaysInMonth(month);
                    var aWeekDays = Array();
                   
                    for(var i=1; i <= TotalDaysInMonth; i++){
                        var dd = new Date();
                        dd.setMonth(month);
                        dd.setDate(i);
                        if(WeekDay == dd.getDay()){
                            aWeekDays[aWeekDays.length] = dd;
                        }
                    }               
                    return aWeekDays;
                }
               
                function RenderWorldClockRegionsPlaceholders(){
                    var output = '<table>';
                   
                    var tr1 = '<tr class="hrow">';
                    var tr2 = '<tr>';
                    for(i=0; i < Regions.length; i++){
               
                        tr1 += "<td class=regionHeader><CENTER>"+Regions[i].RegionName+"<br><center>"+Regions[i].RegionTitle+"</td>";                                                   
                        tr2 += "<td><center><span id="+Regions[i].RegionName+" class=></span></td>";
                                                                                           
                    }
                    tr1 += '</tr>';
                    tr2 += '<tr>';
                    output += tr1 + tr2 +'</table>';

                    document.getElementById("WorldClock").innerHTML = output;
                }
                function SetWorldClockTime(){
                   
                    for(i=0; i < Regions.length; i++){
                        regionTime = new Date();
        
                        regionTime = regionTime.getTime() + (gmtMilisecondsOffset + (Regions[i].RegionTimeOffset * 60 * 60 * 1000));
                        regionTime = new Date(regionTime);
                       
                        var hr = regionTime.getHours();
                        hr = CorrectTime(hr);
                       
                        var min = regionTime.getMinutes();
                        min = CorrectTime(min);
                       
                        var sec = regionTime.getSeconds();
                        sec = CorrectTime(sec);
                       
                        var currentTime = new Date();
                        var boldBegin =  "<span class=otherRegion>";
                        var boldEnd = "</span>";
                       
                      //  window.alert((currentTime.getTime() - regionTime.getTime()))
                      var dif = (currentTime.getTime() - regionTime.getTime());
                        if(dif > -10000 && dif < 10000){
                            boldBegin = "<span class=currentRegion>";
                            boldEnd = "</span>";
                        }
                       
                        var time = boldBegin + regionTime.toDateString() + "<br>" + hr + ":" + min + ":" + sec + " " + Regions[i].DST + boldEnd;
                       
                        document.getElementById(Regions[i].RegionName).innerHTML = time;
                    }
                   
                    setTimeout("SetWorldClockTime()", 1000)
                }
                function CorrectTime(t){
                    if(t < 10)
                        return "0" + t;
                    return t;
                }
                function InitWorldClock(){
                    InitWorldClockRegions();
                    InitDTS();
                    RenderWorldClockRegionsPlaceholders();
                    SetWorldClockTime();
                }
                window.onload=InitWorldClock;


                </script>
    <style type="text/css">
    .hrow {
    font-weight:bold;
    font-family:courier new;
    font-size:12px;
    color: #000000;
    }
    .hrow td{
    4padding: 10px;
    width: 125px;
    }
    .hrow td{
    text-align:center;
    }
    .currentRegion{
    font-weight:bold;
    color: navy;
    font-family:courier new;
    font-size:12px;
    }
    .otherRegion{
    font-weight:normal;
    color: navy;
    font-family:courier new;
    font-size:12px;
    }
    .regionHeader{
        background-color:#CAE1FF;
    }
    </style>           
     </head>
     
     <body>
               
            <div id="WorldClock"></div>
           
            </body>
           
    </html>

     

    I appreciate any help you can provide.

    Thank you,

    Scott

     

    Wednesday, May 4, 2011 8:38 PM
  • First thing you need to do is get read of some of those tags. This is meant to just be a script in the page.

    Get rid of the following, you don't need any of it, and it could potentially cause problems:

     

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 TRANSITIONAL//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>

     <head>
      <title></title>

     </head>
     
     <body>
                        
            </body>
            
    </html>

     

    I'll look at the rest and let you know if I see anything...

    Thursday, May 5, 2011 12:09 AM
  • Will do, thanks Mark I apprecaite the help!

    Scott

    Thursday, May 5, 2011 11:50 PM
  • Hi Mark,

    I Pulled out what I coould, but it is still disabling the Top-Link bar???

     

    Scott

     

    Friday, May 6, 2011 11:36 PM
  • Hey Scott,

    I've not had a chance to try and dissect the script yet, hope to get to it this weekend.  

    Sorry for the delay,

    Mark

    Saturday, May 7, 2011 1:09 AM
  • Thanks Mark,  I hope you can figure it out, because I am just not seeing where the issue is.

    Thaks again for all the help!

    Scott

     

    Monday, May 9, 2011 11:16 PM
  • Hey again Scott,

    I dropped the script in a CEWP as shown below and it seems to work fine and my top link nav bar is fine as well.  Could there be something else on the page responsible for your issues? What type of site is this? Is it a publishing site? Any other info you can provide would be helpful! 

    Thanks,

    Mark

     

          <script language="JavaScript">
          
          var Regions = Array();
          var UTCTime = new Date().getUTCMilliseconds();
          var monthArray = new Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December")
          var gmt = new Date()
          var gmtMilisecondsOffset = gmt.getTimezoneOffset() * 60 * 1000;      
          
          function WorldClockRegion(name, title, offset, SpringDTSMonth, SpringDTSWeekDate, SpringDTSWeekDateOrderNumber, SpringDTSHours, SpringDTSMinutes, FallDTSMonth, FallDTSWeekDate, FallDTSWeekDateOrderNumber, FallDTSHours, FallDTSMinutes){
            this.RegionName = name;
            this.RegionTitle = title;
            this.RegionTimeOffset = offset;
            
            this.SpringDTSMonth = SpringDTSMonth;
            this.SpringDTSWeekDate = SpringDTSWeekDate;
            this.SpringDTSWeekDateOrderNumber = SpringDTSWeekDateOrderNumber;
            this.SpringDTSHours = SpringDTSHours;
            this.SpringDTSMinutes = SpringDTSMinutes;
            
            this.FallDTSMonth = FallDTSMonth;
            this.FallDTSWeekDate = FallDTSWeekDate;
            this.FallDTSWeekDateOrderNumber = FallDTSWeekDateOrderNumber;
            this.FallDTSHours = FallDTSHours;
            this.FallDTSMinutes = FallDTSMinutes;
            this.DST = "";
          }
          
          function InitWorldClockRegions(){
            var index = 0;
    Regions[index++] = new WorldClockRegion("Hawaii","MDSU ONE",-10);
    Regions[index++] = new WorldClockRegion("Pacific","COMEODGRU ONE",-8, 2,0,2,2,0, 9,0,2,0,0); // months and weekdays starts from 0 - SUN
    Regions[index++] = new WorldClockRegion("Atlantic","COMEODGRU TWO",-5, 2,0,2,2,0, 9,0,2,0,0);
    Regions[index++] = new WorldClockRegion("ZULU","(GMT)",0);   // zulu looks like corrected already     
    Regions[index++] = new WorldClockRegion("Italy","EODMU EIGHT",1, 2,0,"LAST",2,0, 9,0,"LAST",3,0);
    Regions[index++] = new WorldClockRegion("Iraq","(OIF)",3);
    Regions[index++] = new WorldClockRegion("Afghanistan","(OEF)",4.5);
    Regions[index++] = new WorldClockRegion("Guam","EODMU FIVE",10);        
        
            
            
            
            
            
            
          }
          function InitDTS(){
            for(var i =0; i < Regions.length;i++){
              if(Regions[i].SpringDTSMonth != null && Regions[i].SpringDTSWeekDate != null && Regions[i].SpringDTSWeekDateOrderNumber != null){
                var springDD = getMonthWeekOrderDay(Regions[i].SpringDTSMonth, Regions[i].SpringDTSWeekDate, Regions[i].SpringDTSWeekDateOrderNumber);
                var fallDD = getMonthWeekOrderDay(Regions[i].SpringDTSMonth, Regions[i].SpringDTSWeekDate, Regions[i].SpringDTSWeekDateOrderNumber);
                
                springDD.setHours(Regions[i].SpringDTSHours);
                springDD.setMinutes(Regions[i].SpringDTSMinutes);
                
                var today = new Date();
                if(springDD.getTime() < today.getTime()){
                  Regions[i].RegionTimeOffset++;
                  Regions[i].DST = "DST";
                }
              }
              if(Regions[i].FallDTSMonth != null && Regions[i].FallDTSWeekDate != null && Regions[i].FallDTSWeekDateOrderNumber != null){
     
                var fallDD = getMonthWeekOrderDay(Regions[i].FallDTSMonth, Regions[i].FallDTSWeekDate, Regions[i].FallDTSWeekDateOrderNumber);
                fallDD.setHours(Regions[i].FallDTSHours);
                fallDD.setMinutes(Regions[i].FallDTSMinutes);
                
                var today = new Date();
                if(fallDD.getTime() < today.getTime()){
                  Regions[i].RegionTimeOffset--;
                  Regions[i].DST = "";
                }
              }                    
            }
          }
          function getTotalDaysInMonth(month){
            var TotalDaysInMonth = 31;
            if(month == 1)
              TotalDaysInMonth = 29;
              
            var d = new Date();
            d.setMonth(month);
            d.setDate(TotalDaysInMonth);
            var check_month = d.getMonth();
            if(month != check_month){
              if(month == 1)
                TotalDaysInMonth = 28;
              else
                TotalDaysInMonth = 30;
            }
            return TotalDaysInMonth;
          }
          function getMonthWeekOrderDay(month, WeekDay, Order){
            var mwkd = getMonthWeekDays(month, WeekDay);
            if(Order == "LAST")
              return mwkd[mwkd.length-1];
            return mwkd[Order-1];
          }      
          function getMonthWeekDays(month, WeekDay){
          
            var TotalDaysInMonth = getTotalDaysInMonth(month);
            var aWeekDays = Array();
            
            for(var i=1; i <= TotalDaysInMonth; i++){
              var dd = new Date();
              dd.setMonth(month);
              dd.setDate(i);
              if(WeekDay == dd.getDay()){
                aWeekDays[aWeekDays.length] = dd;
              }
            }        
            return aWeekDays;
          }
          
          function RenderWorldClockRegionsPlaceholders(){
            var output = '<table>';
            
            var tr1 = '<tr class="hrow">';
            var tr2 = '<tr>';
            for(i=0; i < Regions.length; i++){
          
              tr1 += "<td class=regionHeader><CENTER>"+Regions[i].RegionName+"<br><center>"+Regions[i].RegionTitle+"</td>";                          
              tr2 += "<td><center><span id="+Regions[i].RegionName+" class=></span></td>";
                                                
            }
            tr1 += '</tr>';
            tr2 += '<tr>';
            output += tr1 + tr2 +'</table>';
    
            document.getElementById("WorldClock").innerHTML = output;
          }
          function SetWorldClockTime(){
            
            for(i=0; i < Regions.length; i++){
              regionTime = new Date();
       
              regionTime = regionTime.getTime() + (gmtMilisecondsOffset + (Regions[i].RegionTimeOffset * 60 * 60 * 1000));
              regionTime = new Date(regionTime);
              
              var hr = regionTime.getHours();
              hr = CorrectTime(hr);
              
              var min = regionTime.getMinutes();
              min = CorrectTime(min);
              
              var sec = regionTime.getSeconds();
              sec = CorrectTime(sec);
              
              var currentTime = new Date();
              var boldBegin = "<span class=otherRegion>";
              var boldEnd = "</span>";
              
             // window.alert((currentTime.getTime() - regionTime.getTime()))
             var dif = (currentTime.getTime() - regionTime.getTime());
              if(dif > -10000 && dif < 10000){
                boldBegin = "<span class=currentRegion>";
                boldEnd = "</span>";
              }
              
              var time = boldBegin + regionTime.toDateString() + "<br>" + hr + ":" + min + ":" + sec + " " + Regions[i].DST + boldEnd;
              
              document.getElementById(Regions[i].RegionName).innerHTML = time;
            }
            
            setTimeout("SetWorldClockTime()", 1000)
          }
          function CorrectTime(t){
            if(t < 10)
              return "0" + t;
            return t;
          }
          function InitWorldClock(){
            InitWorldClockRegions();
            InitDTS();
            RenderWorldClockRegionsPlaceholders();
            SetWorldClockTime();
          }
    
          window.onload=InitWorldClock;
    
    
          </script>
    <style type="text/css">
    .hrow {
    font-weight:bold;
    font-family:courier new;
    font-size:12px;
    color: #000000;
    }
    .hrow td{
    4padding: 10px;
    width: 125px;
    }
    .hrow td{
    text-align:center;
    }
    .currentRegion{
    font-weight:bold;
    color: navy;
    font-family:courier new;
    font-size:12px;
    }
    .otherRegion{
    font-weight:normal;
    color: navy;
    font-family:courier new;
    font-size:12px;
    }
    .regionHeader{
      background-color:#CAE1FF;
    }
    </style>      
    
    <div id="WorldClock"></div>
    
     
    

    Tuesday, May 10, 2011 12:53 AM
  • Hi Mark,

    No, its a standard Site workspace using SharePoint 2007 WSS 3.0/MOSS.  It is also on a secure server, so it is not able to access outside sources for time sources...  I have run it on a site with no other WebParts and still had the issue with the TopLink bar being disabled??? What I mean by the TopLink bar being disabled is this, I have the TopLink bar setup so that it has a drop arrow that shows Sub Catagories under the main catagory.  So what happens is that if a catagory on the toplink bar has subsites then that catagory is disabled.  If there is no catagories then that catagory will function.  Does that make sense?

    Thank you,

    Scott



    Tuesday, May 10, 2011 5:37 PM
  • Hey Scott... did you modify the TopLink with script of any kind? If so, what does that script look like?

    Thanks,
    Mark 

    Wednesday, May 11, 2011 1:58 PM
  • No the toplink is not modified, the only thing that I have done to the toplink bar is to add a main directory with sub-directories using the navigation area under site actions so that the bar will show an arrow indicating sub directories and if you hover over it it will drop down and show them.

     

    Thanks,

    Scott

    Wednesday, May 11, 2011 7:53 PM
  • Hey Scott... I'm sure someone smarter than me knows why, but the flyout on the TopLink Nav is breaking because of "window.onload=InitWorldClock;". I can only assume that you are overwriting what SharePoint wants to do on window.onload?

    You can get around this with the code below. I just removed the "window.onload" and called the "InitWorldClock();" directly at the end of the script and all was right with the world.

    Hope it works for you as well... Sorry it too so long to get the answer for you,
    Mark 

          <script language="JavaScript">
          
          var Regions = Array();
          var UTCTime = new Date().getUTCMilliseconds();
          var monthArray = new Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December")
          var gmt = new Date()
          var gmtMilisecondsOffset = gmt.getTimezoneOffset() * 60 * 1000;      
          
          function WorldClockRegion(name, title, offset, SpringDTSMonth, SpringDTSWeekDate, SpringDTSWeekDateOrderNumber, SpringDTSHours, SpringDTSMinutes, FallDTSMonth, FallDTSWeekDate, FallDTSWeekDateOrderNumber, FallDTSHours, FallDTSMinutes){
            this.RegionName = name;
            this.RegionTitle = title;
            this.RegionTimeOffset = offset;
            
            this.SpringDTSMonth = SpringDTSMonth;
            this.SpringDTSWeekDate = SpringDTSWeekDate;
            this.SpringDTSWeekDateOrderNumber = SpringDTSWeekDateOrderNumber;
            this.SpringDTSHours = SpringDTSHours;
            this.SpringDTSMinutes = SpringDTSMinutes;
            
            this.FallDTSMonth = FallDTSMonth;
            this.FallDTSWeekDate = FallDTSWeekDate;
            this.FallDTSWeekDateOrderNumber = FallDTSWeekDateOrderNumber;
            this.FallDTSHours = FallDTSHours;
            this.FallDTSMinutes = FallDTSMinutes;
            this.DST = "";
          }
          
          function InitWorldClockRegions(){
            var index = 0;
    Regions[index++] = new WorldClockRegion("Hawaii","MDSU ONE",-10);
    Regions[index++] = new WorldClockRegion("Pacific","COMEODGRU ONE",-8, 2,0,2,2,0, 9,0,2,0,0); // months and weekdays starts from 0 - SUN
    Regions[index++] = new WorldClockRegion("Atlantic","COMEODGRU TWO",-5, 2,0,2,2,0, 9,0,2,0,0);
    Regions[index++] = new WorldClockRegion("ZULU","(GMT)",0);   // zulu looks like corrected already     
    Regions[index++] = new WorldClockRegion("Italy","EODMU EIGHT",1, 2,0,"LAST",2,0, 9,0,"LAST",3,0);
    Regions[index++] = new WorldClockRegion("Iraq","(OIF)",3);
    Regions[index++] = new WorldClockRegion("Afghanistan","(OEF)",4.5);
    Regions[index++] = new WorldClockRegion("Guam","EODMU FIVE",10);        
        
            
            
            
            
            
            
          }
          function InitDTS(){
            for(var i =0; i < Regions.length;i++){
              if(Regions[i].SpringDTSMonth != null && Regions[i].SpringDTSWeekDate != null && Regions[i].SpringDTSWeekDateOrderNumber != null){
                var springDD = getMonthWeekOrderDay(Regions[i].SpringDTSMonth, Regions[i].SpringDTSWeekDate, Regions[i].SpringDTSWeekDateOrderNumber);
                var fallDD = getMonthWeekOrderDay(Regions[i].SpringDTSMonth, Regions[i].SpringDTSWeekDate, Regions[i].SpringDTSWeekDateOrderNumber);
                
                springDD.setHours(Regions[i].SpringDTSHours);
                springDD.setMinutes(Regions[i].SpringDTSMinutes);
                
                var today = new Date();
                if(springDD.getTime() < today.getTime()){
                  Regions[i].RegionTimeOffset++;
                  Regions[i].DST = "DST";
                }
              }
              if(Regions[i].FallDTSMonth != null && Regions[i].FallDTSWeekDate != null && Regions[i].FallDTSWeekDateOrderNumber != null){
     
                var fallDD = getMonthWeekOrderDay(Regions[i].FallDTSMonth, Regions[i].FallDTSWeekDate, Regions[i].FallDTSWeekDateOrderNumber);
                fallDD.setHours(Regions[i].FallDTSHours);
                fallDD.setMinutes(Regions[i].FallDTSMinutes);
                
                var today = new Date();
                if(fallDD.getTime() < today.getTime()){
                  Regions[i].RegionTimeOffset--;
                  Regions[i].DST = "";
                }
              }                    
            }
          }
          function getTotalDaysInMonth(month){
            var TotalDaysInMonth = 31;
            if(month == 1)
              TotalDaysInMonth = 29;
              
            var d = new Date();
            d.setMonth(month);
            d.setDate(TotalDaysInMonth);
            var check_month = d.getMonth();
            if(month != check_month){
              if(month == 1)
                TotalDaysInMonth = 28;
              else
                TotalDaysInMonth = 30;
            }
            return TotalDaysInMonth;
          }
          function getMonthWeekOrderDay(month, WeekDay, Order){
            var mwkd = getMonthWeekDays(month, WeekDay);
            if(Order == "LAST")
              return mwkd[mwkd.length-1];
            return mwkd[Order-1];
          }      
          function getMonthWeekDays(month, WeekDay){
          
            var TotalDaysInMonth = getTotalDaysInMonth(month);
            var aWeekDays = Array();
            
            for(var i=1; i <= TotalDaysInMonth; i++){
              var dd = new Date();
              dd.setMonth(month);
              dd.setDate(i);
              if(WeekDay == dd.getDay()){
                aWeekDays[aWeekDays.length] = dd;
              }
            }        
            return aWeekDays;
          }
          
          function RenderWorldClockRegionsPlaceholders(){
            var output = '<table>';
            
            var tr1 = '<tr class="hrow">';
            var tr2 = '<tr>';
            for(i=0; i < Regions.length; i++){
          
              tr1 += "<td class=regionHeader><CENTER>"+Regions[i].RegionName+"<br><center>"+Regions[i].RegionTitle+"</td>";                          
              tr2 += "<td><center><span id="+Regions[i].RegionName+" class=></span></td>";
                                                
            }
            tr1 += '</tr>';
            tr2 += '<tr>';
            output += tr1 + tr2 +'</table>';
    
            document.getElementById("WorldClock").innerHTML = output;
          }
          function SetWorldClockTime(){
            
            for(i=0; i < Regions.length; i++){
              regionTime = new Date();
       
              regionTime = regionTime.getTime() + (gmtMilisecondsOffset + (Regions[i].RegionTimeOffset * 60 * 60 * 1000));
              regionTime = new Date(regionTime);
              
              var hr = regionTime.getHours();
              hr = CorrectTime(hr);
              
              var min = regionTime.getMinutes();
              min = CorrectTime(min);
              
              var sec = regionTime.getSeconds();
              sec = CorrectTime(sec);
              
              var currentTime = new Date();
              var boldBegin = "<span class=otherRegion>";
              var boldEnd = "</span>";
              
             // window.alert((currentTime.getTime() - regionTime.getTime()))
             var dif = (currentTime.getTime() - regionTime.getTime());
              if(dif > -10000 && dif < 10000){
                boldBegin = "<span class=currentRegion>";
                boldEnd = "</span>";
              }
              
              var time = boldBegin + regionTime.toDateString() + "<br>" + hr + ":" + min + ":" + sec + " " + Regions[i].DST + boldEnd;
              
              document.getElementById(Regions[i].RegionName).innerHTML = time;
            }
            
            setTimeout("SetWorldClockTime()", 1000)
          }
          function CorrectTime(t){
            if(t < 10)
              return "0" + t;
            return t;
          }
          function InitWorldClock(){
            InitWorldClockRegions();
            InitDTS();
            RenderWorldClockRegionsPlaceholders();
            SetWorldClockTime();
          }
    
          
    
    
          </script>
    <style type="text/css">
    .hrow {
    font-weight:bold;
    font-family:courier new;
    font-size:12px;
    color: #000000;
    }
    .hrow td{
    4padding: 10px;
    width: 125px;
    }
    .hrow td{
    text-align:center;
    }
    .currentRegion{
    font-weight:bold;
    color: navy;
    font-family:courier new;
    font-size:12px;
    }
    .otherRegion{
    font-weight:normal;
    color: navy;
    font-family:courier new;
    font-size:12px;
    }
    .regionHeader{
      background-color:#CAE1FF;
    }
    </style>      
    
    <div id="WorldClock"></div>
     <script language="JavaScript">
     InitWorldClock();
     </script>
    

    • Marked as answer by Danger Powers Wednesday, May 11, 2011 11:39 PM
    Wednesday, May 11, 2011 9:10 PM
  • Mark,

    You are the man!  That did the trick, thank you so much!  I think I was way to close to the issue to ever find it, its good to have a third party check things for you. And besides that, I was getting sick of looking at the script.

    Thank you again!

    Scott

    Wednesday, May 11, 2011 11:39 PM