Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Determining the Document size

Status
Not open for further replies.

julesH

Programmer
Oct 24, 2000
17
US
I'm trying to change the size (height) of a document after it has been loaded into an IFRAME (in an ONLOAD event attached to the IFRAME). I've tried things like 'self.document.body.styles.height' etc.

So far I have been unable to find a property that supplies this information.

Is it possible to return this information?

Many thanks,

JulesH
 
Many thanks for the info.

What I really want though is to determine the length of the loaded document, not the height of the IFRAME.

Regards,

JulesH
 
That's what scrollHeight and scrollWidth do. You might try actually reading the page I listed and maybe code some examples ;-).
 
Maybe my question wasn't phrased that well, but I DID READ your email and links.

I'm not using a DIV for starters, so from what I understand I can't access a scrollHeight property. My IFRAME is contained within a table. What I want is the IFRAME to dynamically change in height depending on the size of the page loaded it contains. The source of the IFRAME is from another site.
 
The example page uses a DIV, but it does not say that scrollHeight and scrollWidth are limited to DIVs. Those values apply to any HTML element that can have scrolling content. To get the value for an IFRAME, simply access (from the parent document):

document.frames["iframe_name"].document.body.scrollHeight

Microsoft has done a pretty good job of making all HTML elements available to scripting methods in IE. It just remains for us poor developers to sort through the mountain of poorly-organized specifications called MSDN to figure it out. Feel free to ask any more questions, as I have spent the last year messing with all of this extensively.
 
Thanks again.

I think problem is one of security now. When the SRC of the IFRAME refers to another site (as in my case), I get an 'Access denied' error.

I did read somewhere that certain properties and methods are restricted when refering to external sites for security reasons (I think thats right)???

JulesH
 
Ooops sorry for my last post (That was something different, I was trying to determine the source of a document in an IFRAME, from another domain, hence the error).

I still can't dynamically resize my IFRAME (that sits in a table) based on the size of its loaded document.

JulesH
 
Why don't you show me your code.

You might have to rewrite the HTML of the IFRAME tag, instead of just dynamically change the property. Try document.all(&quot;iframe_name&quot;).innerHTML = new_value; (I think that's it, but if not it's something like that) to rewrite the HTML string of the <IFRAME> tag.

Also, if it's sitting in a table, then the table might be constraining the size. Instead, you might try just using <IFRAME ID=&quot;whatever&quot; style=&quot;position:absolute; left:200;top:100;width:400;height:340&quot; SRC=&quot;whatever.html&quot;> (Use DHTML style absolute positioning to place the IFRAME exactly where you want it, without any table constraints.)

Basically, AFAIK you can think of an iframe as posessing all the same properties as a DIV layer, and deal with it the wame way you would a DIV. (change visibility, border, position, etc...)
 
Many thanks for the tips Rycamor!!!

I'll try them out first thing tomorrow.

The point about the table constraiing the IFRAME is something that I had thought of and your idea to float the IFRAME outside the table with CSS is something I'll try.

Thanks.
 
Maybe a bit too late, but it might help others ...


Sub button1_onclick
document.getElementById(&quot;my_Iframe&quot;).height=&quot;70&quot;
End Sub

cu
JuGgY ...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top