[Solved] window.history.back() not working right in Chrome, works in Mozilla

I have 2 buttons Submit, which posts the data and gets back validation errors from the server, and a Cancel which calls window.history.back().

I click Submit X number of times (post comes/stays on the page because of validation errors from server)

On Chrome I need to click Cancel X times to go back to the previous page.

On Mozilla I only need to click Cancel once.

I guess Chrome counts the POST requests/direct backs in the history but Mozilla does not. I am not familiar with how that works or jquery. Is there something I can do to fix this?

EDIT: Going to hard code the urls in the link as suggested. Will come back later to try and see if I can do this by sending the referring page url to the edit form to load into the Cancel button, if no one beats me to it.

{{ Form::submit('Create', array('class'=>'btn btn-info')) }}
    <a href="{{ URL::previous() }}" class="back btn btn-danger">Cancel</a>
{{ Form::close() }}

<script type="text/javascript">
    $(document).ready(function() {
        $('a.back').click(function(e) {
            return false;
Enquirer: Phil


Solution #1:

In case you ever need to use back again, the safe cross-browser option was to use history.go(-1);

Respondent: Monir Zaman

The answers/resolutions are collected from stackoverflow, are licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0 .

Leave a Reply

Your email address will not be published.