1

I'm making a page and want some part of my page is reloading automatically. I'm using window.frame[] in firefox but it doesn't work as per requirement. Could you please assist me in correcting the code?

<div class="col s12 m12 l12 xl12" id="ruangdiskusi">
                        <iframe src="schedule.php?cd=2" name"iframe" id="diskusi" style="margin-left: 0%; width:100%; height:487px; overflow-y:scroll; padding:5px; background: rgba(0,0,0,0.1); padding:2%;"></iframe>
                        <script>
                                var id_lansia = "<?php $queri0="Select * From tb_assistant WHERE id_assistant = '$assistant'";   
                                                    $proses0=mysqli_query ($connect,$queri0);
                                                    while ($data = mysqli_fetch_array ($proses0)){
                                                        $idlansia = $data['id_lansia'];
                                                    }echo $idlansia;?>"
                                document.getElementById("diskusi").src = "diskusi.php?cd="+id_lansia;
                                var element = document.getElementById("diskusi");
                                $('#diskusi').scrollTo(element.get(0).scrollHeight);
                                window.setInterval(function() {
            reloadIFrame()
        }, 3000);

        function reloadIFrame() {
            console.log('reloading..');
            document.getElementsByName('iframe').contentWindow.location.reload();
        }
                        </script>
                    </div>
jainashish
  • 4,702
  • 5
  • 37
  • 48
  • `getElementsByName` returns a nodelist, not a single node - that's the problem, since a "nodeList" does not have a contentWindow property - by the way, the error would be clearly shown in the browser *developer* tools console – Jaromanda X Jul 25 '19 at 02:28
  • 1
    You should check out [this](https://stackoverflow.com/a/2064863/4668680) answer. Basically, you'd want to change `document.getElementsByName('iframe')` to `document.getElementById('diskusi').contentWindow.location.reload();`. – Sam Gomena Jul 25 '19 at 02:49

0 Answers0