Reputation: 120
i have an sepa-mandate in a popup window with an delete button inside. When the user click on the delete button he comes to "page2" with an echo to close the iFrame and reload parent page. I try different ways to reload the parent page but nothing works. Here is my last idea with localstorage:
<a href="mandate.php" class="infoboxs" data-fancybox-type="iframe">show mandate</a>
Here is the content of "page2 with the close command and the localstorage parameter
<!-- IF PAGE eq 2 -->
echo "<script>localStorage.setItem('delete', 1); parent.jQuery.fancybox.close();</script>";
<!-- ENDIF -->
Now the parent window is looking for localstorage is set to 1. If its equals 1 it will be set to 0 and the page should be reload.
<script type="text/javascript">
if (localStorage.getItem('delete') == 1)
{
localStorage.setItem('delete', 0);
location.reload();
}
Can any one see whats wrong? Greetings and nice weekend!
EDIT: Before i forgot it, feel free to downvote me! :)
Upvotes: 0
Views: 542
Reputation: 138235
Javascript runs once. You want to check regularily (every second in my code ):
<script type="text/javascript">
setInterval(function(){
if (localStorage.getItem('delete') == 1){
localStorage.setItem('delete', 0);
location.reload();
}
},1000);
</script>
Upvotes: 1