SyncViews Posted January 8, 2008 Share Posted January 8, 2008 I want to use the history object to find the url of the last page a user visited. I tried "document.write(history.previous);" but I get a blank string even though history.length shows there are 6 items in the history... I'm new to js so have no idea why I am getting a blank string so any help would be appreciated. Quote Link to comment Share on other sites More sharing options...
rhodesa Posted January 8, 2008 Share Posted January 8, 2008 Access to those elements is restricted for security reasons. If you want to track where users are coming from (and you are using PHP), you can use the $_SERVER['HTTP_REFERER'] variable. More info can be found here: http://www.informit.com/articles/article.aspx?p=29878&seqNum=4&rl=1 Quote Link to comment Share on other sites More sharing options...
Ken2k7 Posted January 8, 2008 Share Posted January 8, 2008 I want to use the history object to find the url of the last page a user visited. I tried "document.write(history.previous);" but I get a blank string even though history.length shows there are 6 items in the history... I'm new to js so have no idea why I am getting a blank string so any help would be appreciated. document.write("<a href='javascript:history.go(-1)'>Back</a>"); Quote Link to comment Share on other sites More sharing options...
phpQuestioner Posted January 8, 2008 Share Posted January 8, 2008 document.write method is not needed to use the browser history back; all you need is this: history.go(-1); you can add this to a javascript function or a link or some other type of event. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.