Change height of iframe on action

UKSBD

Moderator
  • Dec 30, 2005
    13,063
    1
    2,842
    I have a 3rd party booking form on a page in an iframe

    The height has to be set for the content, but this only needs to be about 200 until an action is taken

    Is there anyway to load the iframe at 200px but have it increase to 1000px after the 1st action is taken?

    Page with booking form is here - https://earhygienist.co.uk/book-here/
     
    At 200 are only displaying part of the page the iframe wraps or it goes to a second page, which is longer?

    If the second, can you use 100% instead of a fixed height?
     
    Upvote 0
    Just to add: I've put a dark background behind the iframe to demonstrate what I am saying better
     
    Upvote 0
    Try one of these:

    <body style="margin:0px;padding:0px;overflow:hidden">
    <iframe src="http://www.youraddress.com" frameborder="0" style="overflow:hidden;height:100%;width:100%" height="100%" width="100%"></iframe>
    </body>

    or

    <body style="margin:0px;padding:0px;overflow:hidden">
    <iframe src="http://www.youraddress.com" frameborder="0" style="overflow:hidden;overflow-x:hidden;overflow-y:hidden;height:100%;width:100%;position:absolute;top:0px;left:0px;right:0px;bottom:0px" height="100%" width="100%"></iframe>
    </body>
     
    Upvote 0
    unfortunately no it is not possible to auto-adjust the iframe height. Not unless you have control of the code on both ends - in that case you can add MutationObserver so the iframed page can send data over to the container page and use javascript to adjust the height.

    but its quite complex to pull off and get right.
     
    • Like
    Reactions: EnterprisePro
    Upvote 0
    neither load the frame at a height

    looking at the iframe source, it has different sections for different stages.

    the initial section only needs to be about 200, but the other sections need to be a 1000
     
    Upvote 0
    unfortunately no it is not possible to auto-adjust the iframe height. Not unless you have control of the code on both ends - in that case you can add MutationObserver so the iframed page can send data over to the container page and use javascript to adjust the height.

    but its quite complex to pull off and get right.
    Yes, ideally the iframe heights would be determined by the source sections, not something i can do :(

    At least having a darker background behind it makes it more obvious that there is content lower down the page
     
    Upvote 0
    You can change the height using Js/jquery. I use it a lot on my forms.

    That being said, cliniko is a dreadful bit of software.
     
    Upvote 0
    You can change the height using Js/jquery. I use it a lot on my forms.

    That being said, cliniko is a dreadful bit of software.
    Your missing the point. yes you can change the iframe height with javascript anytime you want! NO PROBLEM :)

    However the container cannot access any information about the internal iframe, ie. there is no way to know the content changed, how heigh the content is or anything else! So for the OP its useless.
     
    • Like
    Reactions: fisicx
    Upvote 0

    Latest Articles