Remember which frame was from

I want to let the button remember the previous frame where I was from:

For example ,
btn.onPress = function (){go to the previous frame I was from}

Please complete the sentence for me.