Tagged: full height, iframe
-
AuthorPosts
-
July 5, 2022 at 8:18 am #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.
July 5, 2022 at 7:50 pm #1357326Hey 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,
MikeJuly 5, 2022 at 8:04 pm #1357329It looks good on your test page. What is still have wrong here?
July 6, 2022 at 1:25 am #1357338Hi,
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,
MikeJuly 6, 2022 at 9:27 am #1357365Here is my testpage
July 6, 2022 at 12:52 pm #1357392Hi,
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,
MikeJuly 6, 2022 at 2:22 pm #1357401Thank you! Now it works great.
– I try to learn this by myself but sometimes it is not easy… :DJuly 6, 2022 at 5:00 pm #1357417Hi,
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,
RikardMarch 10, 2024 at 10:45 pm #1436890I am trying to use NEARLY the same code — but changing for another href. I am getting a page that has a tiny little horizontal iframe that you have to scroll down to see anything.
Can you tell me what I have done wrong.
Here is my ALB code
[av_codeblock wrapper_element='' wrapper_element_attributes='' codeblock_type='' alb_description='' id='' custom_class='' template_class='' av_uid='av-ltlv93v7' sc_version='1.0']
<iframe id=”nw-kokonaistarjooma” style=”width: 100%; border: none; margin: 0; padding: 0;” src=”https://mailchi.mp/4d1d48071937/grosh-photo-journal-kaluli-scripture-dedication-at-last?e=1d86365c3al”></iframe>
<script>
(function() {
const iframe = document.querySelector(‘iframe#nw-kokonaistarjooma’);
window.addEventListener(“message”, evt => {
if(evt.origin !== ‘https://mailchi.mp/4d1d48071937/grosh-photo-journal-kaluli-scripture-dedication-at-last?e=1d86365c3a’) return ;
if(evt.data.resize) {
iframe.height = evt.data.resize.height;
}
});
}());
</script>
[/av_codeblock]Here is my trial page:
Can you give me a clue, please?
March 10, 2024 at 10:48 pm #1436892This is actually what’s used:
[av_codeblock wrapper_element='' wrapper_element_attributes='' codeblock_type='' alb_description='' id='' custom_class='' template_class='' av_uid='av-ltlv93v7' sc_version='1.0']
<iframe id=”nw-kokonaistarjooma” style=”width: 100%; border: none; margin: 0; padding: 0;” src=”https://mailchi.mp/4d1d48071937/grosh-photo-journal-kaluli-scripture-dedication-at-last?e=1d86365c3a”></iframe>
<script>
(function() {
const iframe = document.querySelector(‘iframe#nw-kokonaistarjooma’);
window.addEventListener(“message”, evt => {
if(evt.origin !== ‘https://mailchi.mp/4d1d48071937/grosh-photo-journal-kaluli-scripture-dedication-at-last?e=1d86365c3a’) return ;
if(evt.data.resize) {
iframe.height = evt.data.resize.height;
}
});
}());
</script>
[/av_codeblock]March 11, 2024 at 12:53 am #1436899Hi,
This only works if the domain is yours, it looks like you are trying to use a mailchi.mp domain it will not work.Best regards,
MikeMarch 11, 2024 at 4:45 am #1436907Thanks, Mike, for answering so quickly.
I tried a workaround, leaving in this code and just changing iframe info to include vh
<iframe id=”nw-kokonaistarjooma” style=”width: 100vw; height: 100vh border: none; margin: 0; padding: 0;” src=”https://mailchi.mp/4d1d48071937/grosh-photo-journal-kaluli-scripture-dedication-at-last?e=1d86365c3a”></iframe>
This achieves enough of what I wanted to make me happy. Not sure the jquery is doing anything, maybe it’s all Iframe? Would be curious to know.
But thanks again for your answer!March 11, 2024 at 10:23 am #1436933Hi,
Glad that you have sorted it out using width: 100vw; height: 100vh
The javascript option above only works on same domain iframes
If you have any further questions please create a new thread and we will gladly try to help you. Thank you for using Enfold.Best regards,
Mike -
AuthorPosts
- The topic ‘iframe full height’ is closed to new replies.