0

So I can't get the IFrame I have to properly resize to the contents of the page it's displaying. I'm on the latest version of chrome, and yes, I know others have made answers on how to do it, but no matter what I try nothing works. It either zooms in on the page (best try I've had yet tbh) or it just stays the same as if I've never changed anything. I don't know S*** about javascript, so please help me out

I've already tried a ton of things, you name it, I've probably tried it.

<script type='text/javascript'>

    $(function(){

        var iFrames = $('iframe');

        function iResize() {

            for (var i = 0, j = iFrames.length; i < j; i++) {
              iFrames[i].style.height = iFrames[i].contentWindow.document.body.offsetHeight + 'px';}
            }

            if ($.browser.safari || $.browser.opera) { 

               iFrames.load(function(){
                   setTimeout(iResize, 0);
               });

               for (var i = 0, j = iFrames.length; i < j; i++) {
                    var iSource = iFrames[i].src;
                    iFrames[i].src = '';
                    iFrames[i].src = iSource;
               }

            } else {
               iFrames.load(function() { 
                   this.style.height = this.contentWindow.document.body.offsetHeight + 'px';
               });
            }

        });

</script>
<iframe src="https://www.thundergaming.net/forums" class="iframe" scrolling="no" frameborder="0"></iframe>

Right now that just zooms in on the page, like it was resized, but the actual window stayed the same. I need the site and the actual IFrame to resize to the IFrames contents, making everything seemless as if you were actually on that page and not looking at an iframe.

  • There is an error in Firefox, it says `SecurityError: Permission denied to access property "document" on cross-origin object` Maybe your server is restricting to access document which is why you cannot get the document size that you need. – TheUnKnown May 24 '19 at 13:42
  • Possible duplicate? https://stackoverflow.com/questions/153152/resizing-an-iframe-based-on-content?rq=1 – BugsArePeopleToo May 24 '19 at 14:34

0 Answers0