Update iframe from .php in separate iframe

I have a page that is built with 7 different frames:

<iframe id="leftframe" src="structure/leftbar.php"></iframe>
<iframe id="headerframe" src="structure/header.php"></iframe>
<iframe id="menuframe" src="structure/menu.php"></iframe>
<iframe id="timerframe" src="structure/times.php"></iframe>
<iframe id="settingsframe"></iframe>
<iframe id="contentframe" name="contentframe"></iframe>
<iframe id="chatframe" src="chat/index.php"></iframe>

      

I have a .php running on a "contentframe". When I click on its button, it sends post

to .php

. The function .php

works correctly, but at the end I want to reload the frame leftframe

.

I have tried suggestions on these pages:

How do I update an IFrame using Javascript? What's the best way to reload / update an iframe using JavaScript?

but none of them work.

in .php

I am trying:

?>

    <script>
        parent.getElementById('leftframe').location.reload();
        alert("Ping");
    </script>

<?php

      

It doesn't work either. Any suggestions?

Thank!

+3


source to share


1 answer


Using a back-end to update an iframe when you can do it client-side is completely wrong.

This works for me:



<script>
     document.getElementById('leftFrame').contentWindow.location.reload(); 
     alert('Ping');
</script>

      

And yes, are you sure you need iframes?
This is definitely not a good practice. Especially in the century of powerful JS and its frameworks and AJAX. It would be better if you update the content of the DOM element instead of updating the iframe.

+3


source







All Articles