Back to previous page with browser back button, OK - back with plain JavaScript, Not OK

2,851 views
Skip to first unread message

Rens van Nijnatten

unread,
May 27, 2013, 8:25:34 AM5/27/13
to ang...@googlegroups.com

Hi everyone,

In my website I have a products page and when you click on a product, it goes to the details of the product.

The link of the product page is: http://localhost:62953/Index.html#/category/1/Foam?price=13.13-26.25&color=Green

The link of the product detail page is: http://localhost:62953/Index.html#/products/2450-Kunda/5036702024506?price=13.13-26.25&color=Green

When I click on the back button of the browser I will be rejected to the product page with the link: http://localhost:62953/Index.html#/category/1/Foam?price=13.13-26.25&color=Green

But I want also a html button on the product detail page.
Behind the button their is plain Javascript with the code: $window.history.back();

When I click the back button, I will be rejected to the following url:http://localhost:62953/Index.html
This is the start url when I launch my website and not the url where I came from.

It looks like the routing in AngularJS sends me to the default url.

Anybody got an idea to fix this?

Scott Elcomb

unread,
May 29, 2013, 6:17:02 PM5/29/13
to ang...@googlegroups.com
On Monday, 27 May 2013 08:25:34 UTC-4, Rens van Nijnatten wrote:

When I click the back button, I will be rejected to the following url:http://localhost:62953/Index.html
This is the start url when I launch my website and not the url where I came from.

It looks like the routing in AngularJS sends me to the default url.

Anybody got an idea to fix this?

Being a new ng user I'm not sure if working with the History API will have any effect on Angular routing; perhaps the pushState method and popstate event would prove useful though.

There's a chapter on the topic at <http://diveintohtml5.info/history.html> and additional docs at <https://developer.mozilla.org/en-US/docs/Web/Guide/DOM/Manipulating_the_browser_history>

Rens van Nijnatten

unread,
May 31, 2013, 2:47:38 AM5/31/13
to ang...@googlegroups.com
Thanks for your response Scott.

But I just got it fixed with this answer on Stack Overflow: http://stackoverflow.com/questions/14070285/how-to-implement-history-back-in-angular-js/14070562#14070562

Op donderdag 30 mei 2013 00:17:02 UTC+2 schreef Scott Elcomb het volgende:
Reply all
Reply to author
Forward
0 new messages