Streaming live at 10am (PST)

Go back link with history.go(-1)


#1

For one of my sites i want to give each page a go back link as breadcrum link

I've been trying to make this but it seems webflow cant create a link like that

If i make a link and select external url and put in the url field : history.go(-1) webflow automaticly makes it http://history.go(-1) and this doesnt work.
Then i thought i give the link a custom attribute but if im trying to use href or onclick im getting the error "this is a reserved name"

So my question here is how can i make a link that goes back to the previous page in webflow?


Going Back a Page Issue
#2

Hi @Joscreative, you can overide the default http:// in a link, if you preface the link you want to use with a backtick character like so:

`history.go()-1

Press enter and the backtick will disappear, but the url will just display history.go()-1

I hope that helps, if not, let me know and I am happy to further assist.

Cheers, Dave


#3

Thanks for the tip Dave.
It removes now the http:// part but when i'm using the link it opens a fresh blanc page instead of going back to the previous page.

im using the following: `javascript:history.go(-1)

Sofar i know that should make me go back 1 page not open fresh new page.


#4

Hi @Joscreative, sorry for the late reply, are you closing that link with a semicolon? ";" I will check on this as soon as I can and then get you an update smile Cheers, Dave


#5

Hi @cyberdave, I'm having the same trouble.

I tried both

`history.go()-1

`history.go()-1;

but nothing happens. Can you help me?


#6

I think history.go(-1) is okay, but it's not great if someone lands on your page as the result of clicking a link, in which case they'll be taken to a new tab/window. In those cases, the back button takes them nowhere. It's always good to have a fallback in that case.

I recommend adding to your header:

<script>
function closebutton(){if(history.length===1){window.location="http://www.YOURURL.com/"}else{history.back()}}
</script>

Then, under link settings, type:

`javascript:closebutton();

This will take the user back, unless there is no back, in which case it'll take them to your URL. To test this, create a link to the page that you're using this button on, and right click that link to open your page in a new tab. Press your new back button, and you'll be taken to your custom URL.


#7