0

Essentially I am trying to create a back button on my navigation lightning component tab so that when the button is pressed it redirects to the previous url. As it stands I have the follows:

Component

<button class="button1" onclick="{!c.redirect}"> Back </button>

Controller

redirect: function (){
            var url = window.location.href; 
            var value = url.substr(0,url.lastIndexOf('/') + 1);
            value= value;
            console.log(value);
            window.open(value, '_self');
           return false;

    } 

I am assuming on the controller i have to add value = value + (previous url), I'm just not sure how to return the previous url, anyone dealt with this issue before?

1 Answer 1

4

Ok so i figured it out I needed to parse the function like so:

    redirect: function (){
            var url = window.location.href; 
            var value = url.substr(0,url.lastIndexOf('/') + 1);
            window.history.back();
            return false;

    }
1
  • seems it's just window.history.back(); not sure if this works on both browser and SF1. Aug 31, 2017 at 23:45

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .