How can I dynamically adjust iframe height in an OS2 theme?

Hello people,

I want to embed an external form via iframe. A custom app is not necessary in this case. An iframe in a custom HMTL section is no problem, but I have to define the height statically. How can I embed an iframe that dynamically adjusts the height? This should be feasible via JS, but how do I integrate it into Shopify? I run an OS2 theme.

I am grateful for any tips!

1 Like

Hello @lukivi ,

Yes it’s possible with JS. You have to assign a class/ID to iframe. After that with JS and with the help of class/ID you have to assign inline css for iframe.
btw process is same as you do in simple html + JS there no change.

Thanks

1 Like

All the HTML I can put into a custom HTML section of my theme. But where can I put the JS?

Check in theme under assets do you have any JS file available if yes you can add it there.
Or you can add it in script tag in theme.liquid or once try to add in same block with tag

1 Like