Saturday, 11 September 2021

Replicating nested and togglable

I'm given to understand that the <frameset> tag is deprecated as of HTML5. Thankfully, Chrome still supports rendering it, and unfortunately, it's currently the only thing I've found that fits my use case.

The important element of the <frameset> tag that other frame-like objects lack is draggable borders, which I haven't been able to get working with iframes even with a prohibitive amount of javascript assistance.

The other important thing in my case is that one of the frames contains a button/link that causes the other frame to disappear or reappear. When that happens, the frames should resize appropriately to fill the space.

My current HTML looks like the following MVCE:

index.html

<html>
<head>
    <script language="javascript">
        function toggleBottomFrame() {
            var bottomFrame = document.getElementById("bottomFrame");
            var horizFrameset = document.getElementById("horizFrameset");
            if (bottomFrame.style.display == "none") {
                bottomFrame.style.display = "";
                horizFrameset.rows = "*,25%";
            } else {
                bottomFrame.style.display = "none";
                horizFrameset.rows = "*,0px";
            }
        }
        document.toggleBottomFrame = toggleBottomFrame;
    </script>
</head>
<frameset id="horizFrameset" rows="*,0px">
    <frameset id="vertFrameset" cols="300px,*">
        <frame id="topLeftFrame" src="buttonpage.html"></frame>
        <frame id="topRightFrame"></frame>
    </frameset>
    <frame id="bottomFrame" style="display:none"></frame>
</frameset>
</html>

buttonpage.html

<html>
<head></head>
<body>
    <button onclick="parent.frameElement.ownerDocument.toggleBottomFrame();">
</body>
</html>

How do I implement the exact same functionality (including, most importantly, the ability to drag around the borders of the frames with my mouse to expand or shrink one of the frames) using non-deprecated functionality?

If possible, I'd like a solution in standard client-side JS or HTML, without needing to import another library like resize.js. This is meant for a very lightweight frontend, and I don't want to bloat it down with libraries I don't need.



from Replicating nested and togglable

No comments:

Post a Comment