0

I wonder if somebody here could help me please? I have a page with multiple frames in it, one of the frames - frame_b, is just a HTML page with 3 HTML forms on it to provide buttons. - ordinarily this moves on to filling the other frames with lists generated from database content.

However, please can someone tell me how it would be possible to, on clicking one of these buttons also reset the content of frame_c, d, e & f back to the original frameset pages? and carry our the action of the form/button pressed please?

Below is the HTML code page for frame_c:

<html>
    <head>
        <title>Button Ribbon</title>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
    </head>
    <body style="background-color: forestgreen;">
        <table>
        <tr>
        <td>
        <form action="phplist1.php" target="frame_c">
        <input type="submit" value="Clients" />
        </form>   
        </td>
        <td>
        <form action="phplist2.php" target="frame_c">
        <input type="submit" value="Horses" />
        </form>   
        </td>
        <td>
        <form action="employees.html" target="frame_c">
        <input type="submit" value="Employees" />
        </form>
        </td>
        </tr>
        </table>
    </body>
</html>

And below is the frameset code:

<html>
    <head>
        <title>Frameset</title>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
    </head>
        <frameset rows="20%,5%,5%,*">
        <frame src="FrameHeader.html" name="frame_a" frameborder="0" scrolling="no">
        <frame src="buttonribbon.html" name="frame_b" frameborder="0">
        <frameset cols="*,*">
            <frame src="blankgreen.html" name="frame_c" frameborder="0">    
            <frame src="blankgreen.html" name="frame_d" frameborder="0">
        </frameset>
        <frameset cols="60%,40%">
            <frame src="blank.html" name="frame_e" frameborder="0">    
            <frame src="blank.html" name="frame_f" frameborder="0">
        </frameset>
</html>

Many Thanks, Graham

..... Subsequently I've added the following:

<form action="phplist1.php" target="frame_c">
            <script type="application/javascript">
                "use strict";
                var list=['frame_c',
                    'frame_d',
                    'frame_e',
                    'frame_f',
                ];
    
            for(var i=0; i<list.length; i++){
            document.getElementByName(list[i])[0].contentWindow.location.reload();
            }
            </script>
        <input type="submit" value="Clients" />

But it doesn't seem to working correctly. Any assistance appreciated.

Many Thanks,

  • Hello, would a JS solution [like this](https://stackoverflow.com/q/86428/2194007) work for you? – rath Sep 19 '17 at 09:31
  • Hi, that's great, thank you!, I have deployed it in the manner below, but it doesn't seem to be working, the phplist still loads OK, but hte frames aren't cleared. Is this how you would expect it to be deployed? – Graham Kendall Sep 19 '17 at 10:30

1 Answers1

0

Make a list of your frame identifiers:

"use strict";
var list=['frame_a',
    'frame_b',
    'frame_c',
    'frame_d',
    ];

and then iterate through them. In your example you don't have IDs so I'll use getElementsByName:

for(var i=0; i<list.length; i++){
    document.getElementByName(list[i])[0].contentWindow.location.reload();
}

According to some comments contentWindow might not be available on Chrome, so you'll need contentDocument instead.

rath
  • 3,655
  • 1
  • 40
  • 53