-
AuthorPosts
-
October 2, 2022 at 5:01 pm #1367335
Hi,
I am trying to open a link to a Google Doc in a lightbox using ?iframe=true. It opens in the iframe but immediately scrolls to the top of the page so that the user has to scroll back down in order to see the lightbox. This isn’t happening with any other external link that I tried. Do you know why this happens and if there is a solution?October 2, 2022 at 7:45 pm #1367345Hey TOTL,
Thanks for the link to your page, I tried to create a test page on my demo for this and I notice that the google spreadsheet link is causing a few errors, first is a jQuery error for Syntax error, unrecognized expression: #gid=9882246?iframe=true this points to the link having a hashtag and question mark causes an error:
since the google link needs the hashtag and the lightbox needs the question mark, I don’t see a way around this. Javascript errors tend to spill down to other functions and scripts.
Once the google spreadsheet is loaded in the lightbox more errors occur about Refused to frame because an ancestor violates the following Content Security Policy directive
I have not seen this before.
So on my test page I uploaded a text document to my site and created a button with the custom class iframe-button and this code in a code block element:<script> (function($) { $(".iframe-button").on('mousedown', function(e) { e.preventDefault(); $("html").css({'overflow-y':'hidden'}); }); $('body').on('click', function() { setTimeout( function() { if($('.mfp-bg').length == 0) { $('html').css({'overflow-y':'scroll'}); } },500); }); }(jQuery)); </script>
and this solved the scrolling of the page for the first button.
But for the second button with the google spreadsheet link this didn’t help.
even adding the google spreadsheet as an iframe on another page and linking to that page in the button as the lightbox still scrolled.
Try taking a screenshot of the google spreadsheet and using that in the lightbox.Best regards,
MikeOctober 10, 2022 at 4:47 pm #1368302or try that new filter in your child-theme functions.php:
add_filter( 'avf_default_lightbox_no_scroll', '__return_true' );
October 10, 2022 at 6:36 pm #1368319 -
AuthorPosts
- You must be logged in to reply to this topic.