Page 1 of 2

How to have an iframe included with automatic height/width

Posted: Wed Jun 13, 2007 6:44 am
by RonnyK
I have used the {pi_iframe}-tag and see that the height of the iframe isn't reflecting the height of the page that is included. Is there a way to have the iframe to show without the scroll-bars and have the full height of the page included. I now gave a fixed height of the max height used, but if the page is not that heigh, you'll end up with a lot of whitespace below the content. I basically want the frame to behave like normal content, so flexible in height and no scrollbars.

Ronny

Re: How to have an iframe included with automatic height/width

Posted: Wed Jun 13, 2007 7:34 am
by cyberman
Embed tag (provided with default CMSms install) has such an option ... please look at tag help.

Re: How to have an iframe included with automatic height/width

Posted: Wed Jun 13, 2007 7:46 am
by RonnyK
Cyberman,

i had tried the embed-tag, but that didn't work as well. I entered the "header=true"-part in the metadata of the content-page, but the iframe didn't go down, it only extends to the height of the menu/sidebar.

I'll create another page with this logic and will post the link to see..

http://work.krijt.eu/index.php?page=beach-lot-embed

Template now:

Code: Select all

{metadata}
<!-- Don't remove this! Metadata is entered in Site Admin/Global settings. -->
Metadata of page:

Code: Select all

{embed header=true}
Content of page:

Code: Select all

<p>{embed url=http://www.nu.nl}</p>
While page www.nu.nl is longer than is just shown in the calling of the embed-tag....


Ronny

Re: How to have an iframe included with automatic height/width

Posted: Wed Jun 13, 2007 8:30 am
by Gregor
Ronny,

I tried something similar with a UDT:

Code: Select all

echo '<__iframe width="100%" height="265" frameborder="0" src="poll/demo_1.php"></__iframe>';
It is possible to use
height="100%"
www.wsv-herkingen.nl

Does this help?
Gregor

Re: How to have an iframe included with automatic height/width

Posted: Wed Jun 13, 2007 8:43 am
by RonnyK
Gregor,

can you show me the way your UDT looks, and the calling of the page. I tried to put iframe directly in the content-page, but it still doesn't show the entire height.

Ronny

Re: How to have an iframe included with automatic height/width

Posted: Wed Jun 13, 2007 8:55 am
by Gregor
Of course

I put {poll} in the template.

Code: Select all

      </div>
       <!-- End Content Area -->
   </div>
   <!-- End Content -->
   <!-- en nu de rechterkant maken voor de content -->
   <!-- 19-03-07 toegevoegd -->
   <div id="rightcontent">
       {content block='Rechter content'}
       {poll}
       <!-- Adsense van Google toegevoegd op 16 apr 2007 -->
       {adsense ad_client="pub-3514636835854223" ad_width="120" ad_height="240" ad_format="120x240_as"}
   </div>

   <!-- Start Footer. Edit the footer in the Global Content Block called "footer" -->
Gregor

Re: How to have an iframe included with automatic height/width

Posted: Wed Jun 13, 2007 9:23 am
by alby
RonnyK wrote: Cyberman,

i had tried the embed-tag, but that didn't work as well. I entered the "header=true"-part in the metadata of the content-page, but the iframe didn't go down, it only extends to the height of the menu/sidebar.

I'll create another page with this logic and will post the link to see..

http://work.krijt.eu/index.php?page=beach-lot-embed

Template now:

Code: Select all

{metadata}
<!-- Don't remove this! Metadata is entered in Site Admin/Global settings. -->
Metadata of page:

Code: Select all

{embed header=true}
There is a smarty error in a javascript in header:

Code: Select all


string(372) "Smarty error: [in metadata template line 7]: syntax error: unrecognized tag: //find the height of the internal page
  var the_height=
    document.getElementById('the_iframe').contentWindow.
      document.body.scrollHeight;

  //change the height of the iframe
  document.getElementById('the_iframe').height=
      the_height; (Smarty_Compiler.class.php, line 439)"
string(116) "Smarty error: [in metadata template line 7]: syntax error: unrecognized tag '' (Smarty_Compiler.class.php, line 583)"
<meta name="Generator" content="CMS Made Simple - Copyright (C) 2004-6 Ted Kulp. All rights reserved." />
A comment?

Alby

Re: How to have an iframe included with automatic height/width

Posted: Wed Jun 13, 2007 9:55 am
by RonnyK
Alby,

thanks for checking, I was "playing" with some height-scripts. I now have embedded the page I want to include, that is NOT working, but with the test-page I tried, www.nu.nl I noticed that the embed, as the other scripts, don't go "all the way down". I now included the good page, which luckily for me, is not as big is the nu.nl page.

http://work.krijt.eu/index.php?page=nu-nl

shows that it is not the full page that www.nu.nl shows original.

The CSS for the iframe:

Code: Select all

#myframe {
  height: 100%;
}
Ronny

I now see that the other page isn't working either as the default is something like 600px. The page is bigger.

Re: How to have an iframe included with automatic height/width

Posted: Wed Jun 13, 2007 10:42 am
by tsw
IIRC there is a problem with iframes from different domains. JS security options disable doing too much to the content of iframe if the source is not on the same domain, including the height query.

last time I had to do something like this it couldnt be done (but that was like two years ago)

Re: How to have an iframe included with automatic height/width

Posted: Wed Jun 13, 2007 11:00 am
by Gregor
I did a test with
http://www.wsv-herkingen.nl/index.php?page=nu

I put a UDT {nu} with the following code

Code: Select all

echo '<__iframe width="100%" height="100%" frameborder="0" src="http://www.nu.nl"></__iframe>';
in the template. The site nu.nl can bescrolled inside the page area (not on the correct place, have no time to solve that one).

Does this help?
Gregor

Re: How to have an iframe included with automatic height/width

Posted: Wed Jun 13, 2007 11:06 am
by RonnyK
Gregor,

that is exactly my issue, i would expect no scrollbar, with the height=100%, I wanted the height to be as high as required.

Ronny

Re: How to have an iframe included with automatic height/width

Posted: Wed Jun 13, 2007 11:33 am
by Gregor
Ronny,

OK, that's the point. What I did to solve it at the wsv-site, I made the iframe area a little larger (in the template). However, if this is not going to work because of the size of the page you want to include, maybe this might help:
http://www.thescripts.com/forum/thread145283.html

I add
scrolling="no"
to the iframe code and now it has no scrolling abillities. I only see a part of the nu.nl-site, might that have to with the site desing of nu.nl???

Gregor

Re: How to have an iframe included with automatic height/width

Posted: Wed Jun 13, 2007 12:35 pm
by cyberman
It's much more tricky, but another way could be to rip content of page you wanna include via php like I've try it here

http://test.cmsmadesimple.de/index.php?page=estate-page

(Yes, I know - all links are broken and page is not valid, but it's only a simple working draft :).)

Re: How to have an iframe included with automatic height/width

Posted: Wed Jun 13, 2007 1:01 pm
by Gregor
oops, Cyberman, the link dos not work at all  ;)

Re: How to have an iframe included with automatic height/width

Posted: Wed Jun 13, 2007 1:28 pm
by RonnyK
Thanks Cyberman,

I'll check that. The only quick disadvantage of that method I see is that links that are clicked in the page "included", are not linkable, as they link relatively, so to your own page instead of remaining inside the iframe/embed.

Ronny