Search code examples
iosdjangosafariuser-experience

Why does safari reload the page when I swipe back on iOS?


I'm building a webpage with Django. When I want to test the project on safari iOS I try to use the swipe back or the back button, but it doesn't perform the right action, instead it reloads the same page.

I have tested the same swipe in another webpage and it works correctly.

Does anyone know why it happens and how to correct it?


Solution

  • I know why this error happened.
    I had a function initialize() that calls google.maps.event.addDomListener(window, 'load', initialize); and inside of the initialize function I had map = new google.maps.Map(document.getElementById("map-details"), mapProp); and a call to a API rest. Inside of the call to the API rest I had the same code map = new google.maps.Map(document.getElementById("map-details"), mapProp);.
    For get the bug fixed I deleted the map declaration in the initialize function and kept the one in the Api call.
    This was the most weird thing I've seen and it was all the fault of google maps.

    Before

    function initialize(){
        map = new google.maps.Map(document.getElementById("map-details"), mapProp);
        $.ajax({
            ...,
            success: {
                map = new google.maps.Map(document.getElementById("map-details"), mapProp);
                ...
            }
        });
    }
    

    After

    function initialize(){
        $.ajax({
            ...,
            success: {
                map = new google.maps.Map(document.getElementById("map-details"), mapProp);
                ...
            }
        });
    }