Streaming live at 10am (PST)

Browser back button doesn't trigger interaction on an anchor link


#1

*EDIT this seems to happen on all links using the back button. Won't load the load trigger, added the share link here: https://preview.webflow.com/preview/esoteric-designs?preview=340d820b94f21b02c40a8adb8eebe26e *

Hi everyone
I have a problem with my interactions when you hit the back button on the browser.

At the loading of a page I have an interaction where everything in the fades in from 0% opacity.

If you go to a normal link back the animation works right but if you go back to an anchor link it won't trigger the animation.

You can see an example here: http://esoteric-designs.webflow.io/design#projects

Just click on any of the projects then click the browser back button on a Mac using Safari or Firefox and it will come to a blank page.

I found someone who wrote some JS to have it go back two clicks but this doesn't work for me because I think they assigned it to a button on the page with a class (.back-button).

Here is that code:

<script type="text/javascript">
    $(".back-button").click(function(e) {

        e.preventDefault();  // This will prevent the default link behavior

        if(window.location.hash) {  // This checks to see if there is a "#" in the current url
          window.history.go(-2);  // If so, this will navigate the browser back by 2 pages  
        } else {
          window.history.go(-1);  // If not, this will only navigate back by 1 page
        }
    });
</script>

Is there something I can change in that code to make it work or is there another workaround people can think of?

Thanks,
-Justin-


#2

Anyone? I couldn't find an example of this in the forums. Should I log it as a bug?


#3

Hi @esoteric_designs, this is just behavior on the browser, to not reload the page on back click, therefore, any load triggers will not execute.

This article from stackoverflow may help: http://stackoverflow.com/questions/19953382/how-to-force-page-refresh-on-browser-back-click

Also, just a tip, since it involves custom code, it is good to put this kind of question in the Code Help category :slight_smile:

I hope this helps!


#4

This topic was automatically closed after 60 days. New replies are no longer allowed.