Help - Search - Members - Calendar
Full Version: Flexible iframe?
HTMLHelp Forums > Programming > Client-side Scripting
Hotshot
Well, I've been revamping my clan/guild website and I've run into a little problem. I've decided to add an iframe on one of my pages, in which there is some text as well as 3 buttons, which make 3 different tables visible while making the other two invisible (javascripting stuff tongue.gif). The problem is that it seems I need to use a specific 'height' for the iframe, but I want to have one that opens up and extends on its own as needed instead of having a whole lot of blank space ready for the table to appear, or keep the space small and force the viewers to scroll down without a scroll bar. I can post a link to the associated files as they appear on my site if it would help, or if my explanation didn't make sense biggrin.gif. Any ideas? Should I instead be asking in a more javascript-oriented forum?

Thanks in advance,

Hotshot
http://www.clangis.com
Christian J
Iframes cause problems just like ordinary frames: http://htmlhelp.com/faq/html/frames.html#frame-problems

That said, you can make an iframe change size to fit its content with something like this: http://www.dynamicdrive.com/dynamicindex17/iframessi2.htm

QUOTE(Hotshot @ Jan 16 2007, 08:35 PM) *

Should I instead be asking in a more javascript-oriented forum?

In fact there is a client-side scripting forum, so I move the topic there. wink.gif
Hotshot
Thanks a lot, that's exactly what I was looking for. smile.gif
Hotshot
Uh oh, I tested and messed with it after a late very late lunch and I haven't been able to get it to work.

The original frame shows up fine, but the tables don't seem to affect the iframe size in any way. Here is the page in question: http://www.clangis.com[Slash]apply (view source to referance the code)

I've ID'd the frame as 'app', properly call to it later on (ctrl+f "step 1" to skip to it), but the tables seem to be getting ignored in the size calculation. I realize things are a bit ugly for now, but I'm trying to get the main functionality to work before I make it all 'nice' looking.

Luckily this page isn't actually public yet (per say), unless google or some other search engine spiders are quick to pick up on new web content.

edit:
QUOTE(active users list)
Google.com Viewing Topic: Flexible iframe? Today, 04:30 PM

Wow, they're not wasting any time. Good thing I didn't parse the link. tongue.gif
Christian J
QUOTE(Hotshot @ Jan 16 2007, 10:25 PM) *

The original frame shows up fine, but the tables don't seem to affect the iframe size in any way. Here is the page in question: http://www.clangis.com[Slash]apply (view source to referance the code)

Do you mean www.clangis.com/apply/ ? Which links are supposed to change the IFRAME's content?

There are also some validator errors that might cause bugs.

QUOTE
Luckily this page isn't actually public yet (per say), unless google or some other search engine spiders are quick to pick up on new web content.

edit:
QUOTE(active users list)
Google.com Viewing Topic: Flexible iframe? Today, 04:30 PM

Wow, they're not wasting any time. Good thing I didn't parse the link. tongue.gif

This forum uses rel="nofollow" attributes on external links in topics, which according to http://www.google.com/support/webmasters/b...amp;ctx=sibling should stop Googlebot from crawling that link:

"you can also instruct Googlebot not to crawl individual links by adding rel="nofollow" to a hyperlink"


But I'm not sure if that statement can be trusted, see e.g. http://www.seroundtable.com/archives/006926.html

To be on the safe side, disallow search engine spiders on your own site.
Hotshot
QUOTE
Do you mean www.clangis.com/apply?


Yes, I decided to simplify (for the users) and better-organize things (for myself) by creating a folder for every top-level doccument (.com/apply.php or .html would become .com/apply/ or just /apply).

QUOTE
Which links are supposed to change the IFRAME's content?


The script you linked above is almost at the start of the header in the source of the page. The frame's ID is 'app'

CODE
***********************************************/

//Input the IDs of the IFRAMES you wish to dynamically resize to match its content height:
//Separate each ID with a comma. Examples: ["myframe1", "myframe2"] or ["myframe"] or [] for none:
var iframeids=["app"]


And later on I call to it as

CODE

<iframe id="app" src="../sources/app.html" width="664" marginwidth="0" marginheight="0" frameborder="0" vspace="0" hspace="0" style="overflow:visible; width:100%" scrolling="no"></iframe>


I used to have it set up my own way but later decided to convert almost entirely to the example shown in the directions for that script. I think I've figured out the problem though - the problem is that this script isn't what I'm looking for, because I think it was designed to change the size when the target iframe loads a different page, and not when the same page is modified through javascript. I'm toggling the tables with a code like this:

CODE

<button onclick="document.getElementById('table1').style.display='block';document.getElementById('table2').style.display='none';document.getElementById('table3').style.display='none';">Diablo2:LoD</button> - If you want to join us, and you consider D2 to be the game that you are most likely to be playing. <br><br>

<button onclick="document.getElementById('table1').style.display='none';document.getElementById('table2').style.display='block';document.getElementById('table3').style.display='none';">MapleStory</button> - If you want to join us, and you consider MS to be the game that you are most likely to be playing. <br><br>

<button onclick="document.getElementById('table1').style.display='none';document.getElementById('table2').style.display='none';document.getElementById('table3').style.display='block';">Other</button> - If you want join the community and not the clan/guild yet (if you're already in another one and currently don't plan to leave, or don't play the above games).<br><br><br>
// --------- and this is how I set up all of the tables. Only the table ID changes
<table border="0" cellpadding="0"  id="table1" style="display:none">


I can post (or better yet, PM you) the frame source file if you want to take a look at it. Unless any of the above code is wrong (which I don't expect), I don't think validator errors are the cause of my troubles since nothing else is really associated.

OT:
Christian J
QUOTE
this script isn't what I'm looking for, because I think it was designed to change the size when the target iframe loads a different page, and not when the same page is modified through javascript.

Yes that's why I wondered why there were no links to change framed page with. tongue.gif

I think the best solution is not to load those tables in an IFRAME in the first place. Why not include the them on the parent page with PHP?
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2010 Invision Power Services, Inc.