How to convert HTML framesets / frames to iframes in a PHP setting – 2020 scenario and solution

  frame, frameset, html, iframe, php

Much expert advice has been read here on this topic. Though, sometimes this was very general and did not incorporate the suggestion not to use Bootstrap’s or Flexbox’ solutions to this dilemma.

For all those of you who have a "historic" HTML frameset with several frames I would like to show you the way how I did this transformation from the original PHP code files. Being very grateful for all the professional advice I personally had been able to collect on stack overflow, I would like to return something here.

The basic layout structure is like this:

    +---------------------------------------------------------+
    |                                                         |
    +---------------------------------------------------------+
    |                                                         |
    +---------------------------------------------------------+
    |     |                 frameBody                   |     |
    |     |                                             |     |
    |     |                                             |     |
    |     |                                             |     |
    |     |                                             |     |
    |     |                                             |     |
    |     |                                             |     |
    |     |                                             |     |
    +---------------------------------------------------------+
    |                                                         |
    +---------------------------------------------------------+

After having logged in successfully from login.php, I am being forwarded to site.php which takes over the steering of the entire website. In this file, all the conditions for switching from conditions to conditions and, thus, to corresponding other PHP files is managed.

site.php, however, also takes care of the principal layout of the website, here in the old frameset / frame / noframes way (please excuse the lengthiness of the code example, but I want to show you how nicely short and well-structured an iframe solution can be):

    <?php
        // Lots of definitions and introductory stuff, not relevant here
    ?>

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="content-type" content="text/html; charset=<?= strtolower($CHARSET) ?>" />
        <meta name="author" content="whoever" />
        <meta name="date" content="<?= date('r', filectime($_SERVER['SCRIPT_FILENAME'])) ?>" />
    <title><?= $sCompanyName ?></title>
    </head>

    <frameset name="alles" cols="20,*,20" framespacing="0" frameborder="0" border="0" />
        <frame name="emptyCol" src="emptyCol.php" scrolling="no" noresize="noresize" />
        <frameset rows="20,50,120,*,40,20" framespacing="0" frameborder="0" border="0" />
            <frame name="emptyRow" src="emptyRowHeader.php" scrolling="no" noresize="noresize" />
            <frame name="frameTitle" src="frameHeader.php" scrolling="no" noresize="noresize" />
            <frame name="frameMenu" src="frameMenu.php" scrolling="no" noresize="noresize" />

    <?php
        if (isset($_REQUEST['sBody']) && $_REQUEST['sBody'] == 'login')
        echo '<frame name="frameBody" src="login.php' . $sLanguageString . '">';
        else {
    ?>

            <frameset name="Frame1" cols="225,1,*,1,225" framespacing="0" frameborder="0" border="0">
                <frame name="frameMenu" id="userMenu" src="userMenu.php" />
                <frame name="frameBody" src="<?= $sBody . (strlen($sURLParameterString) > 1 ? $sURLParameterString : '') ?>" />
                <frame name="patientMenu" id="patientMenu" src="patientMenu.php"/>
            </frameset>
            <frame name="frameTitle" src="frameFooter.php" scrolling="no" noresize="noresize" />
            <frame name="emptyRow" src="emptyRowFooter.php" scrolling="no" noresize="noresize" />
        </frameset>
        <frame name="emptyCol2" src="emptyCol2.php" scrolling="no" noresize="noresize" />

    <?php
        }
    ?>

        <noframes>
        <body>

    <?php
        setSysMsg($oSysMsg->getExpression('general', 'noFrameSupport', 'This site is based on frames. But your browser doesn't support frames.<br />Your should choose another internet browser.'));
        echo getLastSysMsg();
    ?>

        </body>
        </noframes>
    </frameset>
    </html>

What are the obstacles now for an easy conversion?

Source: Ask PHP

LEAVE A COMMENT