Iframe-resizer: Two iframes on the same page, only on target runs the getPageInfo

Created on 16 Feb 2018  路  7Comments  路  Source: davidjbradshaw/iframe-resizer

I have a simple page with two iframes that I init with iFrameResize.

The sizing works fine on both iframes but only one iframe recives the info of the parent page thru the method parentWindow.getPageInfo

The readyCallback: runs on both iframes
but the metod parentWindow.getPageInfo runs only on the first iframe page to be initalized.

Is this a bug or em I doning something wrong?

bug

All 7 comments

I've no idea and would need a simple test case before I could understand the issue.

Hi David thanks for you fast response
Check out this demo
Only the method getPageInfo in index_f1.html will write to the console when scrolling in iframe.html
test.zip

and thanks for a greate library anyway we use it a lot

@lukashanssondn I have this same issue and it has to do with the debounce of the getPageInfo function.
See #405 as well.

You can verify this by modifying iframeResizer.js as follows:

function sendPageInfoToIframe(iframe,iframeId){
            // function debouncedTrigger(){
                trigger(
                    'Send Page Info',
                    'pageInfo:' + getPageInfo(),
                    iframe,
                    iframeId
                );
            // }

            // debouce(debouncedTrigger,32);
        }

Thanks Thomas this gave me the hope back to have this work :-)

Do you want to make a PR for that?

@davidjbradshaw Yes, I would like to remove the debounce from sendPageInfoToIframe() and move it to startPageInfoMonitor() so it wraps the for-loop instead. So that the messages get sent to all frames or get debounced:

        function debouncedMessageSender() {
          ['scroll','resize'].forEach(function(evt) {
            log(id, type +  evt + ' listener for sendPageInfo');
            func(window,evt,sendPageInfo);
          });
        }

        debouce(debouncedMessageSender,32);   

Does that sound OK?

Fixed in v3.6.0

Was this page helpful?
0 / 5 - 0 ratings

Related issues

frederic117 picture frederic117  路  4Comments

thomasbilk picture thomasbilk  路  4Comments

mouse0270 picture mouse0270  路  6Comments

snarfed picture snarfed  路  5Comments

TarsisDragomir picture TarsisDragomir  路  5Comments