473,581 Members | 2,307 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Dynamic resizing of iframes based on content height


Does anyone know of how I could dynamically resize an iframe based on
the content's height (for IE) so that no scrollbar appears for the iframe?
The content will be from a different domain. I have searched on the web and
have seen solution like this

function resize() {
var oframe = document.getEle mentById("frame ID");

//var odoc = oframe.document ; //(1)
var odoc = oframe.Document ; //(2)

var obody = odoc.body;

oframe.height = obody.scrollHei ght;

The html :
<iframe onload="resize( )" src=http://different.comai n.content border="0"
....... > </iframe>

I have seen 2 solutions on the web, the only difference being lines (1) and
(2) get substitued.
My browser is version IE 6.

It seems that the solution with line (2) works perfectly when the content is
from the same domain but gets a Permission Error if the domain is different.

When the content is from a different domain solution (1) does not give
Permission error, but instead the scrollHeight is significantly smaller
than the actual content. Even if the content is from the same domain it
still gives the wrong size.

So my question is
1) What is the difference between oframe.document and oframe.Document , why
does it give different results?

2) More importantly, how can I dynamically adjust the iframe size based on
the content height from a different domain?
Jul 23 '05 #1
1 7147
Peter wrote:
Does anyone know of how I could dynamically resize an iframe based on
the content's height (for IE) so that no scrollbar appears for the iframe?
The content will be from a different domain. [...]

The Same Origin Policy prevents this almost certain violation of author's
rights. Your goal would be a contradiction to the purpose of an iframe
Jul 23 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

by: khothikhe | last post by:
Can someone help me here because this is really killing me! the problem is, i have this javascript code in my aspx page that i want it to work on almost all browsers, especially opera and safari : function resize(){ displayFrm = document.getElementById("ifrmDisplay"); innerDoc = (displayFrame.contentDocument) ?displayFrm.contentDocument...
by: Paul Fi | last post by:
I have this problem with iframes: i want to resize iframe's height when the window inside the frame is resized or when the src attribute of iframe changes so make the height of iframe equal to the size window's body scrollHeight so that way i dont need any scrolls for my iframe but the let page containing the iframe do the scrolling for the...
by: f.ruecker | last post by:
Hey Guys, I've done my research for a script that dynamically adjusts the height of the Iframe, but none of the scripts have the features, which I all need. Maybe one of you can help me: 1. The site contained in the Iframe is no on the same Domain nor Server as the main page 2. I can't put any code in the Iframe (YES, I do have...
by: visu | last post by:
Hi , I need a solution for my problem with IFRAME in firefox. The problem is that i ve to make the IFRAME to increase in its height to displays its whole content dynamically .i ve set scrolling=0 ,i dont want the scroll bars to appear in the IFRAME. I ve achieved this somehow thru javascript in IE.. but it is not working in Firefox.. is...
by: Grimm | last post by:
I am developing an internalk inteface that integrates alot of seperate tools into one interface. The current version uses one Iframe inside a div layer for positioning. Currently the seperate web tools do not have the ability to stay active. As you switch from tool to tool the previous information is lost unless you use a Back button. I need to...
by: dli07 | last post by:
Hello, I'm trying to convert a piece of code that creates a dynamic vertical resizing bar in a table from internet explorer to firefox. It's based on a post from http://blogs.crankygoblin.com/blogs/geoff.appleby/pages/50712.aspx. I've also read the post on this topic by bggraphics, but he doesn't arrive at a final result. The main problem I...
by: =?Utf-8?B?UiBSZXllcw==?= | last post by:
Hi! This discussion may help other programmers get a better idea of how to save uploaded images through a website. Why? Well currently, I save 3 versions of every uploaded image on my own little website: 1. Small: DOWNsize of original image to be used as a thumbnail. 2. Medium: DOWNsize of original image to be used as user...
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.