title: Javascript show info by default
body: <p>I have a Javascript code to calculate the next coach to two destinations. I think that I have written everything ok, but when I join the website I must click on a tab to see the information. Why is it not showing it by default? Also, is there a way to access to one tab from the URL (ex. if I want tab #c to be showed active by default, I go to url.com/index.php#c)?<br>
  My actual code is this:  </p>
  
  <pre><code>// Timetable constructor, including the arrays of bus times
  var Timetable = function(){
  var campusMF = ["06:00", "06:30", "06:50", "07:05", "07:25", "07:55", "08:25", "08:40", "09:00", "09:25", "10:00", "10:20", "10:30", "11:15", "12:00", "12:10", "12:30", "13:00", "13:25", "14:00", "14:35", "14:50", "15:05", "15:25", "16:00", "16:20", "16:35", "17:00", "17:25", "18:05", "18:20", "18:35", "19:10", "20:00", "20:10", "20:35", "21:00", "21:25", "21:55", "22:10", "23:05"];
  var campusSA = [];
  var campusSU = [];
  var leamMF = ["06:05", "06:45", "07:10", "07:35", "07:45", "08:05", "08:35", "09:05", "09:25", "09:40", "10:05", "10:40", "11:00", "11:20", "12:05", "12:40", "12:55", "13:10", "13:35", "14:05", "14:40", "15:05", "15:25", "15:40", "16:10", "16:40", "17:05", "17:20", "17:35", "18:05", "18:50", "19:15", "19:40", "20:05", "20:40", "20:55", "21:05", "21:35", "22:15", "22:45", "23:05"];
  var leamSA = [];
  var leamSU = [];
  
  var today = new Date().toUTCString().slice(0, 16);
  
  // Convert time strings to actual dates (doesn't work past midnight yet)
  for(var i=0, l=campusMF.length; i&lt;l; i++){
  campusMF[i] = new Date(today+" "+campusMF[i]);
  }
  for(var i=0, l=leamMF.length; i&lt;l; i++){
  leamMF[i] = new Date(today+" "+leamMF[i]);
  }
  
  // This will be where we work out what timetable to use
  var campus = campusMF;
  var leam = leamMF;
  
  // A variable for updating the time left automatically
  var update = setTimeout($.noop, 0);
  
  // The body of the Timetable object, returns a HTML string
  // that will look nice on the page containing the time til
  // the next bus at the given stop ('c' or 'l');
  this.next = function(place){
  clearTimeout(update); //Updating now so cancel the planned one
  if(place == "l")
    var times = leam;
  else
    times = campus;
  var now = new Date();
  var d; // Time to wait in mins
  var next = '&lt;span id="time"&gt;';
  for(var i=0, l=times.length; i&lt;l; i++){
    if(times[i].getTime() &gt;= now.getTime()){
      d = (times[i].getTime()-now.getTime())/(1000*60);
      if(d &gt;= 60)
        next += Math.floor(d/60)+"&lt;/span&gt;hores i "+Math.round(d % 60)+" minuts.";
      else
        next += Math.round(d)+"&lt;/span&gt; minuts.";
      break;
    }
  }
  var fn = arguments.callee;
  var _this = this;
  update = setTimeout(function(){
    document.getElementById('info').innerHTML = fn.call(_this, place);
  },(d+0.5-Math.floor(d+0.5))*60*1000+1000);
  // The time here makes it so an update happens at just gone 30
  // seconds past each minute (when round actually changes the value)
  return next;
  }
  }
  
  // Lets use what we've built!
  var timetable = new Timetable();
  
  // Update the screen even if jquery isn't available for some reason
  document.onready = function(){
  document.getElementById('info').innerHTML = timetable.next('c');
  }
  
  
  $(document).ready(function(){
  $('#c').click(function(){
    if($(this).hasClass('active'))
      return;
    document.getElementById('info').innerHTML = timetable.next('c');
    $(this).addClass('active')
           .siblings().removeClass('active');
  });
  $('#l').click(function(){
    if($(this).hasClass('active'))
      return;
    document.getElementById('info').innerHTML = timetable.next('l');
    $(this).addClass('active')
           .siblings().removeClass('active');
  });
  });
  </code></pre>
  
  <p>The URL where is posted is <a href="http://poldiloli.com/bus" rel="nofollow noreferrer">http://poldiloli.com/bus</a></p>