Find articles on computer software, programming, ASP.net, Sql server, databases, C#, websites, Internet, Windows, Outlook macros.
Only works on the same domain.
Wasted way too much time on cross browser support, but it must be done since Firefox and IE deliver about the same number of visitors to my websites. As to the rest of the browsers, forget about it.
My original article is here.
/Articles/tabid/159/asp_net_sql/176/Dynamically-Resize-an-Iframe-to-Fit-Content-and-Prevent-Scrollbars.aspx
Here is the updated code to support my current versions of Firefox and IE as of this date. Good luck.
//--------------------------------------------------------- // Automatically resizes iframe to scroll height to fit contents. // // If your page and the page contained inside the iframe are on different domains, // to allow your function to execute, add this code to the page contained in the iframe, // where domainoriginal is the domain name of the page containing the iframe. //// <script type="text/javascript">// document.domain=domainoriginal;// </script>//function br_page_Iframe(src, iclass, istyle, id) {if (!id) id = 'br_iframe_' + this.iframe_count++;var iid = ' id="' + id + '"';if (!iclass) iclass = '';else iclass = ' class="' + iclass + '"';if (!istyle) istyle = '';else istyle = ' style="' + istyle + '"';var ionload='br_page_Iframe_Adjust(' + "'" + id + "'" + ');';ionload = ' onLoad="' + ionload + '"';var out = '<iframe'+ iid+ ionload+ iclass+ istyle+ ' src="' + src + '"'+ ' frameborder="0" marginheight="0" marginwidth="0" scrolling="no"'+ ' width="100%"'+ ' height="0"'+ '></iframe>';document.write(out);}//---------------------------------------------------------function br_page_Iframe_Adjust(id) {var iframe=document.getElementById(id); // Iframeif (!iframe) return;var content=iframe.contentWindow || iframe.contentDocument; // Cross browsersif (!content) return;var doc=content.document;if (!doc) return;var body=doc.body;if (!body) return;var height=body.clientHeight; // Content inside Iframeiframe.height=height;}//---------------------------------------------------------
To use:
br_page_Iframe("http://www.mywebsite.com/myframe.com");
Name (required)
Email (required)
Website
Notify me of followup comments via e-mail
AWeber Email List Marketing Test Drive
Use email marketing to convert targeted subscribers to customers. Let the system sell itself for you!