title: how to call javascript function on page load in mvc3
body: <p>I have a javascript function </p>
  
  <pre><code>function relativeTime(time) {
  
  var period = new Date(time);
  var delta = new Date() - period;
  
  if (delta &lt;= 10000) {   // Less than 10 seconds ago
      return 'Just now';
  }
  
  var units = null;
  
  var conversions = {
      millisecond: 1,     // ms -&gt; ms
      second: 1000,   // ms -&gt; sec
      minute: 60,         // sec -&gt; min
      hour: 60,       // min -&gt; hour
      day: 24,        // hour -&gt; day
      month: 30,      // day -&gt; month (roughly)
      year: 12            // month -&gt; year
  };
  
  for (var key in conversions) {
      if (delta &lt; conversions[key]) {
          break;
      }
      else {
          units = key;
          delta = delta / conversions[key];
      }
  }
  
  // Pluralize if necessary:
  
  delta = Math.floor(delta);
  if (delta !== 1) { units += 's'; }
  return [delta, units, "ago"].join(' ');
  
  }
  </code></pre>
  
  <p>that give relative time difference like facebook comment.</p>
  
  <p>How can i call this function in my view. I am using mvc3.
  i am getting time from database like,</p>
  
  <pre><code>        &lt;span&gt;
              @item.wallTimeStamp
          &lt;/span&gt;
  </code></pre>
  
  <p>instead of that i want to call javascript function,</p>
  
  <p>i have a tag</p>
  
  <pre><code>&lt;span&gt;
      //call javascript function that will display time difference in this tag
     &lt;/span&gt;
  </code></pre>
  
  <p>how can i do that?</p>