Dynamic Iframe for External Domain

Thread Solved

Join Date: Jan 2009
Posts: 68
Reputation: jonow is an unknown quantity at this point 
Solved Threads: 0
jonow jonow is offline Offline
Junior Poster in Training

Dynamic Iframe for External Domain

 
0
  #1
Mar 7th, 2009
I have been looking everywhere for a piece of code that made the height of an iframe auto adjusts while showing contentment from an external domain. (ex: my domain mydomain.com showing google.com). I need a script that does that

Or something that may be harder is that it counts the number of divs with a certain id and multiplies that my a number to make the iframe height, Possible?

Thank You
Reply With Quote Quick reply to this message  
Join Date: Sep 2008
Posts: 178
Reputation: FlashCreations is an unknown quantity at this point 
Solved Threads: 13
FlashCreations's Avatar
FlashCreations FlashCreations is offline Offline
Junior Poster

Re: Dynamic Iframe for External Domain

 
0
  #2
Mar 7th, 2009
Probably not, there is no simple way (or any way at all for that matter) to determine content height unless it is a style on the page (Ex. something like maybe:
  1. .myDivThatIWantTheHeightFrom {
  2. height: 50px;
  3. }

I'm not sure though even in that case if you could determine height.
FlashCreations
(aka PhpMyCoder)

About Me | My Blog | Contact Me
Reply With Quote Quick reply to this message  
Join Date: Jan 2009
Posts: 68
Reputation: jonow is an unknown quantity at this point 
Solved Threads: 0
jonow jonow is offline Offline
Junior Poster in Training

Re: Dynamic Iframe for External Domain

 
0
  #3
Mar 7th, 2009
So are you saying that lets say these is a div that is set to 50 px through css in the external domain i can make the iframe that height?
Reply With Quote Quick reply to this message  
Join Date: Sep 2008
Posts: 178
Reputation: FlashCreations is an unknown quantity at this point 
Solved Threads: 13
FlashCreations's Avatar
FlashCreations FlashCreations is offline Offline
Junior Poster

Re: Dynamic Iframe for External Domain

 
0
  #4
Mar 7th, 2009
Yes simply add the height property to the iframe like so:
  1. <iframe src="http://externaldomain.com" height="50"></iframe>

Now that I think about it, there might be a JavaScript fix that could help, but I'm not sure it would work, nor would it work everywhere.
Last edited by FlashCreations; Mar 7th, 2009 at 7:58 pm. Reason: OCD me rewriting something that sounds off
FlashCreations
(aka PhpMyCoder)

About Me | My Blog | Contact Me
Reply With Quote Quick reply to this message  
Join Date: Jan 2009
Posts: 68
Reputation: jonow is an unknown quantity at this point 
Solved Threads: 0
jonow jonow is offline Offline
Junior Poster in Training

Re: Dynamic Iframe for External Domain

 
0
  #5
Mar 8th, 2009
No but i want to do it dynamically so when a new page loads it loads to that height.
Reply With Quote Quick reply to this message  
Join Date: Jan 2009
Posts: 1,325
Reputation: almostbob has a spectacular aura about almostbob has a spectacular aura about 
Solved Threads: 161
almostbob's Avatar
almostbob almostbob is offline Offline
Nearly a Posting Virtuoso

Re: Dynamic Iframe for External Domain

 
0
  #6
Mar 8th, 2009
do it ANother way
frameset instead of iframe
this is a file 'external.php' that we use to load outside files under a little header that says external file and a menu the file takes a parameter $ext that is the file to load
  1. <?php ob_start('ob_gzhandler'); ?>
  2. <!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.01 Frameset//EN' 'http://www.w3.org/TR/html4/frameset.dtd'>
  3. <html xmlns='http://www.w3.org/1999/xhtml'>
  4. <Title>Linking <?php if(!$ext){$ext = '/home2.php';} echo $ext ; ?></Title>
  5. <LINK rel='StyleSheet' HREF='/style.css.php' TYPE='text/css' MEDIA='all'>
  6. <script language='javascript' type='text/javascript' src='/script.js.php'></script>
  7. <frameset rows='100,*'>
  8. <frame name='Menu' SRC='menu2.php' TITLE='Menu'>
  9. <frame name='Content' SRC='<?php echo $ext; ?>' TITLE='Content'>
  10. </FRAMESET>
  11. </body>
  12. </html>
  13. <?php ob_flush(); ?>
(stylesheets and javascripts are .php files, mod_gzip.)
Last edited by almostbob; Mar 8th, 2009 at 3:20 pm.
Failure is not an option It's included free
If at first you dont succeed, join the club
Of course its always in the last place you look, you dont keep looking after you find it

Please mark solved problems, solved
Reply With Quote Quick reply to this message  
Join Date: Sep 2008
Posts: 178
Reputation: FlashCreations is an unknown quantity at this point 
Solved Threads: 13
FlashCreations's Avatar
FlashCreations FlashCreations is offline Offline
Junior Poster

Re: Dynamic Iframe for External Domain

 
0
  #7
Mar 8th, 2009
And that's exactly what I'm saying. It could be done with JavaScript but it won't be compatible everywhere and there's no guarantee it will work. It would be something like this...
  1. <html>
  2. <head><titleDynamic iFrame Height</title>
  3. <script type='text/javascript'>
  4. var divName = 'testDiv'; //ID of the div you want to adjust height for
  5. function dynamicIframe(name)
  6. {
  7. if(name=='') name = divName;
  8. document.getElementById('iFrame').style.height = document.getElementById('iFrame').document.getElementById(name).style.height;
  9. }
  10. </script>
  11. </head>
  12. <body>
  13. <iframe src="thispage.html" height="100" width="100%" id="iFrame" onload="javascript:dynamicIframe();"></iframe>
  14. </body>
  15. </html>
Simply replace divName with the name of the tag you would like to adjust height of iFrame for.
FlashCreations
(aka PhpMyCoder)

About Me | My Blog | Contact Me
Reply With Quote Quick reply to this message  
Join Date: Jan 2009
Posts: 68
Reputation: jonow is an unknown quantity at this point 
Solved Threads: 0
jonow jonow is offline Offline
Junior Poster in Training

Re: Dynamic Iframe for External Domain

 
0
  #8
Mar 8th, 2009
so there is no way possible? That sucks.
Reply With Quote Quick reply to this message  
Join Date: Sep 2008
Posts: 178
Reputation: FlashCreations is an unknown quantity at this point 
Solved Threads: 13
FlashCreations's Avatar
FlashCreations FlashCreations is offline Offline
Junior Poster

Re: Dynamic Iframe for External Domain

 
0
  #9
Mar 8th, 2009
No I didn't say that. You can try AlmostBob's suggestion or my JavaScript solution.
FlashCreations
(aka PhpMyCoder)

About Me | My Blog | Contact Me
Reply With Quote Quick reply to this message  
Join Date: Jan 2009
Posts: 68
Reputation: jonow is an unknown quantity at this point 
Solved Threads: 0
jonow jonow is offline Offline
Junior Poster in Training

Re: Dynamic Iframe for External Domain

 
0
  #10
Mar 8th, 2009
I will just leave it alone. The set up i have is ok, with scrolling iframe
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:



Other Threads in the HTML and CSS Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC