Changing the Size of an iFrame when div Inside of iFrame Make Page Bigger on Button Press
Hopefully this question makes sense. I have a page that I've created that I want users to be able to embed into their site. The page has a div the expands when a button is clicked. I want the iFrame to be the same height as the site prior to the button click and I want the iFrame to get bigger to accommodate the size of the expanded div after the button is clicked. Is开发者_StackOverflow this possible?
You can do this, not sure on full browser support. You are going to need to have access to both the iframe contents and the page calling the iframe. You can then resize based on some css tricks and javascript.
Here's a good article describing the process: http://www.wolfcreekconsulting.com/support/techlib/web/DynamicallyResizedIframesPart2.php
I hope that's helpful!
You cannot change an iFrame's size from inside itself. The script must be included on the page where they embed the site. Even then I'm not sure it will work if the button is inside the iFrame.
if I understand correctly, what you want is to set iframe height after onclick event? so you add id to iframe and div, get div's height and change iframe's one? like onclick = $('#myIframe').height($('#myDiv').height()); (assuming using jQuery). Not sure if this exact code will work, but that's the general idea.
精彩评论