JavaScript Back Button

I’ve tried several JavaScript back buttons but I end up going back and forth between two pages. I guess because each page was the “previous page”!

Here’s what I mean:

Click from page “A” (i.e. regular product page)
Go to page “B” (i.e. account Login) NOTE: Back button works to go back to product page at this point,
Go to page “C” (i.e. start an account, because they didn’t login because they don’t have an account yet)

Then if they decide not to start an account and click back they go from start an account page “C” back to “B” okay. But if they click the back button on Account Login page “B” they go back to page “C” agian. Back and forth between “B” and “C”.

Understand?

I need them to be able to progressively back up to the page “A” they were at.

Here is the current JavaScript I’m using on page “B”:

<a href="#" onclick="history.go(-1);return false;" class="back-link">

Why bother? Every browser since the year dot has had its own ‘back’ button, and 99.9999999% of all internet users know how it works. Recreating basic browser functionality with JavaScript is a waste of time, is fraught with problems, and only ends up complicating matters and frustrating users when it doesn’t work exactly as they expect it to.

Yeah I know. But it kind of looks professional :slight_smile:

I thought of some more reasons.

It gives the customer a feeling of security that he is not being trapped when he sees the back button.

It enhances user experience because they don’t have to move their mouse as far. haha

At least make sure there’s a fallback for those with JavaScript off. But I agree with Stevie that this is a waste of time and also asking for trouble. There’s nothing unprofessional about the Back button, and predictable and familiar behavior is very important for customers.

You would need to actually generate the entire back button from JavaScript in order that those who don’t have JavaScript don’t feel trapped because the back button you put in the web page doesn’t work.

Yeah, I’m working on a Magento cart and it’s not operational without javascript anyway. So a button sure isn’t going to hurt it. I think most everyone trust javascript nowdays too.

O dear, that’s really bad practice. JS should be an extra layer to add functionality. The content / basic functionality should not depend on it.

Not when it doesn’t work, it doesn’t! :cool:

I’m really not convinced it looks professional - most serious webbists disdain JavaScript back buttons, and I doubt other people will notice one way or the other. A JavaScript back link doesn’t ‘un-trap’ them. If you’re worried about people feeling trapped in a process, you should look at offering a proper Cancel button rather than fudging the issue.

I’m passionately opposed to engendering ‘learned helplessness’, ie habituating people into using the wrong tool for the job because you’ve made it easy for them to do so, which then discourages them from learning how to use the tools properly in the first place. JavaScript widgets for going back, changing text size and printing the page are prime examples of this.

I agree. It works without javascript only one can’t checkout. I guess checking out is the main propose of a eCommerce site though. I think it the worst short coming of the Magneto cart.

Yeah, it not professional if it doesn’t work. I like the cancel button idea, but still one would want to be redirected back to the page they were viewing. I’m thinking some kind of php script might be better.

It’s usually better to use a server-side language like PHP, because it doesn’t depend on what your user’s setting are to work.