javascript - Resizing iFrame dynamically with 100% width -
I have several embedded IFrames on my site. I am in the process of giving it a new look and need to fit them in the new design.
I can easily fit the width by setting them all in 100% width, but altitude is all different ... how can I resize them and save the ratio?
Thank you! By using jquery, you can get the breadth and height of the frame in something like this:
w = $ ("# iframe"). Width (); H = $ ("# iframe") height (); With this information you can calculate the aspect ratio of given iframe (ratio = w / h). Then you can calculate a new width or height for each iframe. I'm guessing that your design (naturally) will limit the width of each frame, so that you basically - & gt; NewHeight = ratio * maxWidth
You now have your new dimensions and you can set them up appropriately.
Comments
Post a Comment