skauntey Posted April 24, 2016 Report Share Posted April 24, 2016 Hi all, I am looking for a working solution to resize iframe height and width. I have used an iframe to embed a submission form on my website. This form has various rules (4 in total) in place so as per option selected by the users , the form will change its height. Ideally, I would like to resize the iframe accordingly. Will appreciate if somebody could share a successful solution they might have come across? I have browsed a bit and found an interesting discussion thread on stack overflow . I tried various alternatives BUT with no success! The code that I have currently embedded on the webpage is below, ------------------------ <head> <script language="JavaScript"> function autoResize(id){ var newheight; var newwidth; if(document.getElementById){ newheight = document.getElementById(id).contentWindow.document .body.scrollHeight; newwidth = document.getElementById(id).contentWindow.document .body.scrollWidth; } document.getElementById(id).height = (newheight) + "px"; document.getElementById(id).width = (newwidth) + "px"; } </script> </head> <body> <iframe src="Caspio. URL of Datapage" width="100%" id="iframe1" marginheight="0" frameborder="0" onLoad="autoResize('iframe1');"></iframe></body> ---------------------- Any help most welcome! Thanks in advance. K Quote Link to comment Share on other sites More sharing options...
MayMusic Posted October 13, 2016 Report Share Posted October 13, 2016 Try this: <iframe name="" id="iFrame1" title="02 Inline Providers_with FY choice" src="URL">Sorry, but your browser does not support frames.</iframe> <script type="application/javascript"> function resizeIFrameToFitContent( iFrame ) { iFrame.width = "100%"; iFrame.height = "500px"; } var iFrame = document.getElementById( 'iFrame1' ); resizeIFrameToFitContent( iFrame ); // or, to resize all iframes: </script> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.