Close pop up with native back button

Hello, I have created a few pop up modals for some pictures on the mobile version of my site. I have used the interaction and show and hide features on webflow. Once the user clicks on the picture, a pop up appears. The only way for the user to close the pop up, is to click the back arrow at the top of the screen I have placed.

Question: Is there a way for the user to press the back button on their browser or mobile phone (android), and have the pop up close? This way they can either use the button I have created, or the back buttons they are already used to?

Thanks in advance!


Here is my site Read-Only: LINK
(how to share your site Read-Only link)

This would require some custom code, but this would get you started:

<script>
$('.example-image-class').click(function() {
    window.location.hash='example-hash-added-to-URL'
});
</script>

You could also search on Google for adding URL hash on click

Thank you for the quick response. Where do I paste this?

Sorry. This code won’t work as is. It’s just the general concept to get you started.