Search code examples
javascriptbackbone.jswebwindowbrowser-history

Reading previous URL in Backbone.history


Can you read Backbone.history to see the previous URL the user was on within your app? If not, is there a way to extend Backbone routes to keep track?


Solution

  • Not by default and with vanilla Backbone. It is definitely possible to extend the Router to keep a readable history. Take a look here.

    The quick and dirty solution, however, is to use document.referrer, that most of the time will give you the previous URL the window was at.