Revenue Source

Welcome to the Revenue Source affiliate marketing forums.

You are viewing our internet marketing and SEO forums as a guest which gives you limited access to most of our discussions.  By joining our free community, you will have access to post affiliate marketing topics, communicate privately with other members (PM), exchange SEO strategies, and access many other special features.  Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems, please don't hesitate to contact us.

Go Back   Revenue Source > Affiliate Marketing Hangout > Internet Marketing Articles > SEO / SEM
Reload this Page How to dynamically adjust an iframe’s height
Tags: , , ,

Reply
 
LinkBack Thread Tools Search this Thread
Old
  (#1 (permalink))
SEO Blogs is Offline
Revenue Source Veteran
SEO Blogs is worth a listen.SEO Blogs is worth a listen.SEO Blogs is worth a listen.
 
SEO Blogs's Avatar
 
Join Date: Jul 2005
Posts: 834
   
How to dynamically adjust an iframe’s height - 01-14-2008

Suppose you want to include a child iframe on your page. You’d like to resize the height of the child iframe so that it doesn’t show a scrollbar. That is, you want something that looks like this:

Here’s one way you can do it. First, make the iframe that you want to include. I made a file “child-frame.html” that looks like this:

Child frame

[COLOR=”#ffffff”]
Child frame.

Child frame.

Child frame.

Child frame.

Child frame.

Child frame.

Child frame.

Child frame.

[/color]


Now in the parent frame, you can make code like this:

Parent frame


// Firefox worked fine. Internet Explorer shows scrollbar because of frameborder
function resizeFrame(f) {
f.style.height = f.contentWindow.document.body.scrollHeight + “px”;
}

Parent frame.

Parent frame.

Parent frame.

Parent frame.








You can also see a live example of resizing an iframe height dynamically.
What does this code do? When the body of the parent frame loads, it looks up the document element “childframe” which corresponds to the iframe. Then the page calls a function resizeFrame(). The function sets the height of the frame to be the scrollHeight, which effectively removes the scrollbar.
The only tricky bit is the “frameborder=0 border=0″ attributes on the frame. If you leave off the frameborder attribute, Internet Explorer will assume that the frame should have a nonzero border, but it won’t include the frame border in the value it returns for scrollHeight. The net effect is that IE will show a scrollbar unless you add “frameborder=0″.
It always annoys me to dive into cross-browser development when it feels like things should be standardized. Looks like it annoys other people too.
Anyway, feel free to rip on my code in the comments, but I was looking for a simple, working example of setting an iframe’s height so that the iframe wouldn’t have a scrollbar.


How to dynamically adjust an iframe’s height - Read More...
  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is On
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads for: How to dynamically adjust an iframe’s height
Thread Thread Starter Forum Replies Last Post
Dave Dash's Blog: Dynamically adjusting your page title in symfony Affiliate Blogs Programming Help 0 07-20-2007 05:15 PM
Zend Developer Zone: Dynamically Creating Compressed Zip Archives With PHP Affiliate Blogs Programming Help 0 06-05-2007 05:04 PM



© 2004-6 RevenueSource.com.  All rights reserved.  Do not duplicate or redistribute in any form.
This website and its logos/design are property of RevenueSource.com.  All rights reserved. vBSEO 3.2.0 RC7


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34