Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #1357252

    I’d need an iframe full height, but did not managed to do it. Here is the the code I used on code block.

    #1357326

    Hey tammiviestinta,
    Thanks for posting your code block snippet, but your javascript has errors and the iframe had the height set to auto with inline css, below is the corrected script and the link to my test page.

    Best regards,
    Mike

    #1357329

    It looks good on your test page. What is still have wrong here?

    #1357338

    Hi,
    It looks like the same code I posted, did you check to ensure that the quotes didn’t turn into curly quotes when you copied the code?
    Otherwise, I will need to see a test page to see if you have any errors, as you noted this is working on my test page.

    Best regards,
    Mike

    #1357365

    Here is my testpage

    #1357392

    Hi,
    You have two errors, first your origin url is not wrapped in commas like the code I corrected above,
    you have: if(evt.origin !== https://www.your.site) return ;
    it should be: if(evt.origin !== 'https://www.your.site') return ;
    second error is that you are still using the jQuery statement for the iframe.height
    you have: iframe.height = ${evt.data.resize.height}
    it should be: iframe.height = evt.data.resize.height;
    So it looks like you are using the old code instead of the corrected code.
    If the code on your page backend is the new code I posted then you should try clearing your server cache, if it is an object-oriented cache such as Memcached, Redis, Varnish, Litespeed, etc. then it is still using the old page.
    Please review this code, note that the urls are not your so you will need to adjust.

    <iframe id="nw-kokonaistarjooma" style="width: 100%; border: none; margin: 0; padding: 0;" src="https://www.your.site/index.html"></iframe>
    
    <script>
    (function() {
    const iframe = document.querySelector('iframe#nw-kokonaistarjooma');
    window.addEventListener("message", evt => {
    if(evt.origin !== 'https://www.your.site') return ;
    if(evt.data.resize) {
    iframe.height = evt.data.resize.height;
    }
    });
    }());
    </script>

    Best regards,
    Mike

    #1357401

    Thank you! Now it works great.
    – I try to learn this by myself but sometimes it is not easy… :D

    #1357417

    Hi,

    Great, I’m glad that Mike could help you out. Please let us know if you should need any further help on the topic or if we can close it.

    Best regards,
    Rikard

Viewing 8 posts - 1 through 8 (of 8 total)
  • You must be logged in to reply to this topic.