3

I have a problem with the history.back() function.

I have three page A,B,C:

  • the first one (A) has a link to the second (B) and the link contains parameters (?id=..).
  • B has a link to C
  • I go back from C to B with history.back().

The problem is that back() function use in fact the A to B link (from the history) that contains the parameters but I need to change these.

So I changed history.back() to a simple href but of course, now if I click on back, I go back to C page (what I don't want).

So is there a solution to use back() with different parameters? (I use Angular, may be something can help).

A.html :

<body ng-controller="AuthentCtrl">
    <div align="center">
        <button ng-click="location.href = 'view/listing.html?id=' + id + '&first=' + newAuthent;">Go!</button>
        <br/>
    </div>
</body>

B.html

<body onload="init()">
<script>
    function init(){
        var params = location.search.substring(1).split('&');
        id = params[0].split('=')[1];
        var firstCo = params[1].split('=')[1];
        // execute some code, function of parameters
    }
</script>
</body>

C.html

<body>
    <div align="center">
        <button ng-click="history.back()">Go!</button>
        <br/>
    </div>
</body>
2
  • Can you create a Plunkr or a fiddle for this issue? I wish to know exactly how you are using the back() functionality. Apr 30, 2013 at 11:11
  • I'm gonna update my post with code
    – axvo
    Apr 30, 2013 at 12:44

1 Answer 1

2

There's no way to alter your history with javascript.

Have you tried using the referrer property to figure out on Page "B", if you're coming from page "A" or "C"?

1
  • Yes and in both case it's the URL I use in the href of A button. Thanks for your answer, I'll find something else!
    – axvo
    Apr 30, 2013 at 14:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.