Ok, to check the image that changed, you must go to the other page.
so while redirecting you can post a data to the next page that the image should change. Then after redirecting to the next page, you can request the post data if the image should change. If it should, then change the source, and if it souldn’t, then display the default image.
You can do this in many ways, but if I was there I would do it like this.
<form method="post" id="theForm" action="REDIRECT_PAGE.php">
Then put some hidden fields in that form.
<input type="hidden" name="sould_change" value="yes">
</form>
Then when the button clicked.
Your_button.addEventListener("click", document.getElementById('theForm').submit());
Then on the next page. you can use AJAX or any server-side script like PHP to read the data and put a condition like,
if( $_POST['sould_change'] == "yes"){
//change the image source
}else{
//keep it default
}