My FeedDiscussionsHeadless CMS
New
Sign in
Log inSign up
Learn more about Hashnode Headless CMSHashnode Headless CMS
Collaborate seamlessly with Hashnode Headless CMS for Enterprise.
Upgrade ✨Learn more
iFrameception - we have to go deeper!

iFrameception - we have to go deeper!

Jan Vladimir Mostert's photo
Jan Vladimir Mostert
·Mar 3, 2016

Ever wondered what happens when placing an iFrame on your page and then telling that iFrame to point at itself?

Many years ago, this was possible due to browser developers not stopping you from doing this bizarre thing. Firefox used to stop going deeper after about 6 levels, Chrome used to go on and on until all memory was exhausted, then the whole PC would start slowing down until the browser just died, internet explorer would eventually throw a blue screen of death and take out the whole PC.

A few moments ago I was wondering if they patched the issue after all these years ... indeed they have, after playing around a little bit, I managed to get it working again :-D

How deep can you go before your browser crashes and how badly does it burn ...

<html>
<head>
    <script type="text/javascript">
        function incept(counter){
            document.body.style.backgroundColor = '#' + (Math.random() * 0xFFFFFF << 0).toString(16);
            var location = window.location.href;
            if (location.indexOf("?") === -1){
                document.getElementById("iframe").src = window.location + "?" + (counter);
            } else {
                document.getElementById("iframe").src = window.location + "&" + (counter);
            }
        }
    </script>
</head>
<body onload="incept(1)">
<iframe id="iframe" src="" width="800" height="600"/>
</body>
</html>

Ok, yes, this code has no use other than for messing around when you're supposed to be working on something else ...