Keyword

Magnific Popup Iframe - How to show that the iframe is loadi

  • Niels Klint
  • Niels Klint's Avatar Topic Author
  • Offline
  • New Member
  • Learning by doing
More
7 years 11 months ago - 7 years 11 months ago #154140 by Niels Klint
Is there a way to make the iframe show a loading message or animation until the content arrives?
I this case the site I want to view in the iframe is loading very slowly

Joomla 3.5.1
PHP 7
K2 v2.7.1 [Dev Build]
Site here...
I tried the solution on stackoverflow here...
But I'm not sure i understand, how to do it right
I've tried to add the following scripts - only one at a time, and both to the template body, head and the K2 item override.
<script type="text/javascript">
callbacks: {
    beforeAppend: showIframeLoading
}

var showIframeLoading = function() {
    var curLength = 0;
    var interval = setInterval(function() {
        if ($('iframe').length !== curLength) {
            curLength = $('.column-header').length;
            $('.mfp-content').hide();
            $('.mfp-preloader').show();

        }
    }, 50);
    this.content.find('iframe').on('load', function() {
        clearInterval(interval);
        $('.mfp-content').show();
        $('.mfp-preloader').hide();
    });
};
</script>
and this
<script type="text/javascript">
callbacks: {
 beforeAppend: function() {
    console.log('before iframe is added to DOM');
    this.content.find('iframe').on('load', function() {
      console.log('iframe loaded');
    });
 }
}

var showIframeLoading = function() {
    var curLength = 0;
    var interval = setInterval(function() {
        if ($('iframe').length !== curLength) {
            curLength = $('.column-header').length;
            $('.mfp-content').hide();
            $('.mfp-preloader').show();

        }
    }, 50);
    this.content.find('iframe').on('load', function() {
        clearInterval(interval);
        $('.mfp-content').show();
        $('.mfp-preloader').hide();
    });
};
</script>
The last returns an error in chrome - Uncaught SyntaxError: Unexpected token (
Can You help?
Last edit: 7 years 11 months ago by Niels Klint.

Please Log in or Create an account to join the conversation.

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
7 years 11 months ago #154165 by Krikor Boghossian
Replied by Krikor Boghossian on topic Magnific Popup Iframe - How to show that the iframe is loadi
This means that you are closing the ) sign too early.
Perhaps you are not closing a function properly }.

In the link you sent us, you are using Fresco and I cannot find any issues.

JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

Please Log in or Create an account to join the conversation.

  • Niels Klint
  • Niels Klint's Avatar Topic Author
  • Offline
  • New Member
  • Learning by doing
More
7 years 11 months ago #154205 by Niels Klint
Thanks for the comment, but java is not one of my disciplines, so I did find another solution with some CSS i the template custom.css
I changed the iframe background from #000 (black) to transparent and added a couple of :before tags to display my own load text and animation

Please Log in or Create an account to join the conversation.

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
7 years 11 months ago #154255 by Krikor Boghossian
Replied by Krikor Boghossian on topic Magnific Popup Iframe - How to show that the iframe is loadi
Nice to hear that issue has been resolved Niels.

JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

Please Log in or Create an account to join the conversation.


Powered by Kunena Forum