0

To go back to the appropriate tumblr page, we're using:

<a href="javascript:history.go(-1)"> Back </a>

However, we're getting a lot of traffic directly from the twitter app, and this stops the function working. Is there a way so that if the history.go doesn't work (or takes you outside the site), it will just take you to index.html?

This is one of the pages the history button is on: http://lexican.info/post/49265445109/sesquipedalophobia

Thanks for any help at all.

2 Answers2

0

Try to check how many page in the history list with history.length:

http://www.w3schools.com/jsref/prop_his_length.asp

Simon Wang
  • 2,843
  • 1
  • 16
  • 32
0

Sadly I don't think this is possible as there is no relationship between a post and what page of the index the post is displayed on.

mikedidthis
  • 4,899
  • 3
  • 28
  • 43
  • Would it be possible to send it to the default homepage? –  May 02 '13 at 11:51
  • Yes, if you update the `href="/"` that should return the user to the homepage. – mikedidthis May 02 '13 at 12:03
  • Sorry, but only if the history.go doesn't work? A if history.go works, go back. If not, go to index? –  May 02 '13 at 12:17
  • I am not 100% sure, as its not something I have done before. A quick search pulls this up (document.referrer) : http://stackoverflow.com/a/7651297/2312574 You could try checking if the referrer is from your site, with something like: http://stackoverflow.com/a/4362869/2312574 If your site is the referrer, keep the link as ` Back ` else change the link to ` Back ` Again I am not 100% sure if this will work or what implications incognito mode or opening a link from an app would have on the referrer. – mikedidthis May 02 '13 at 12:34