sandy1028 Posted February 28, 2011 Share Posted February 28, 2011 <div class="sectabsbg"> <ul id="sectabs" class="sectabs"> <li>2011</li> </ul> </div> <div class="sectabsbgnew"> <ul class="sectabsnew"> <li>2010</li> </ul> </div> I am calling the src link in an iframe and hard coding the height. In some src links it has <div> tags as above. if there is no <li> tags inside sectabs or sectabsnew, then I have to reduce the height of the iframe source. Please tell me how can I do this. Quote Link to comment Share on other sites More sharing options...
xenophobia Posted February 28, 2011 Share Posted February 28, 2011 Correct me if I'am wrong, you wanted the iframe to automatically adjust the height based on the content inside. Please refer to this tutorial: http://www.mattcutts.com/blog/iframe-height-scrollbar-example/ Please note, if the source (src) of the iframe is out of the domain, your auto height adjust will not work as the script could't get the height of the content due to the security restrict of the client browser. Quote Link to comment Share on other sites More sharing options...
sandy1028 Posted March 1, 2011 Author Share Posted March 1, 2011 Thanks. yes, iframe source is out of the domain. <iframe frameborder=0 border=0 src=”http://abc.com/navigation/74550.cms” name=”childframe” id=”childframe” width=100% > Still the scroll bar appears. In the URL "http://www.mattcutts.com/blog/iframe-height-scrollbar-example/" <script type=”text/javascript”> // Firefox worked fine. Internet Explorer shows scrollbar because of frameborder function resizeFrame(f) { f.style.height = f.contentWindow.document.body.scrollHeight + “px”; } </script> how to find the exact height of the src=”http://abc.com/navigation/74550.cms” Quote Link to comment Share on other sites More sharing options...
xenophobia Posted March 2, 2011 Share Posted March 2, 2011 As I said, there is no way to get external source page's height. What you can do is, create a PHP file as a proxy to the external source. Eg: http://www.yourdomain.com/load_external_source.php In your code: <?php if (isset($_GET['url'])) { $url = urldecode($_GET['url']); $html = file_get_contents($url); echo $html; } ?> So you can query external source using local domain: http://www.yourdomain.com/load_external_source.php?url=http://abc.com/navigation/74550.cms With that, the page will be loaded and now your javascript can get the height of the content. Please try out, cheers 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.