title: Using Javascript: How to create a 'Go Back' link that takes the user to a link if there's no history for the tab or window?
body: <p><em><strong>EDIT-2:</strong> None of the answers seem to work. Not even the one I previously marked as the answer of this question. Any help is appreciated. Thanks.</em></p>
  
  <p>First, I have googled for a how-to on creating a 'Go Back' link that allows the user to return to the previous page, and these are two ways of doing it:</p>
  
  <pre><code>&lt;a href="javascript:history.go(-1)"&gt;[Go Back]&lt;/a&gt;
  </code></pre>
  
  <p>and...</p>
  
  <pre><code>&lt;a href="#" onclick="history.go(-1);return false;"&gt;[Go Back]&lt;/a&gt;
  </code></pre>
  
  <p>Which of these two is a better choice? And why? (Also, please shed some light on browser compatibility.)</p>
  
  <p>That's one half of the question. Now if mine is the first page the user is visiting, the 'Go Back' link wouldn't work, right? (As there's no pre-existing history for the window or tab.) In that case, I want the link to fallback and take the user to <a href="http://example.com">http://example.com</a>.</p>
  
  <p>i.e. if history exists, the user is taken to the previous page, and if it doesn't he's taken to <a href="http://example.com">http://example.com</a>.</p>
  
  <p>How do I do that? Hope someone can help.</p>
  
  <p><strong>EDIT:</strong> Please note that I do not know JavaScript, so kindly make your answer explanative. Thanks.</p>