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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

document.getElementById not working in IE 1

Status
Not open for further replies.

Ghodmode

Programmer
Joined
Feb 17, 2004
Messages
177
Location
NZ
In IE 6 (6.0.2900.2180.xpsp_sp2_gdr.050301-1519), I get the error message "Object does not support this property or method" for the following line in the [tt]onload[/tt] property of the [tt]body[/tt] tag.

Code:
container     = document.getElementById( 'container' );

This entire page is (necessarily) in a frameset and that does seem to be related because the error goes away when I open the page in a window by itself.

How do I access the object with an id of "container" if it's in a frameset?

Thank you,

--
-- Ghodmode
 
Try this, with frames being referred to by index or by name.
[tt] var x=top.frames[0].document.getElementById("container");
[/tt]
 
It's not working for me, but I still think you're right.

I'm working with nested framesets as implemented by x-desktop. When I use [tt]top.framename.document.getElementById("container")[/tt], it tells me ... is null or not an object., but I think that's because the frame I'm trying to access is not at the top.

Maybe, in my case, it's [tt]top.frame[0].frame[0].document.getElementById();[/tt]

I'm going to play with things like [tt]this[/tt] and [tt]parent[/tt] until I get something that works. I'll post my solution when I figure it out. If nothing else, I could probably write a loop that goes through all of the frame indexes until I find one that contains an object with the ID I'm looking for.

Thanks... I think you have set me on the right track.

--
-- Ghodmode
 
It's as easy as [tt]this[/tt] ...

I was trying to get at the height of an object after assigning it to a variable like this:
Code:
heading_table = this.document.getElementById('heading_table');
ht_height = heading_table.offsetHeight;
... but that gives me the same error message I first posted.

So, I combined the two lines. Here's the complete block of code, if you're curious. I don't know why, but this works :
Code:
if ( browser('msie') ) {
[b]    ht_height = this.document.getElementById('heading_table').offsetHeight;[/b]
} else {
    ht_height = get_style( heading_table, 'height' );
    ht_height = ht_height.substring( 0, ht_height.length - 2 );
}

fr_height = document.body.offsetHeight;
r_height  = fr_height - ht_height;

this.document.getElementById('deliveries').style.height =
    r_height + 'px';

My problem is solved, but I'm still curious about this. Does anyone know why this works?

--
-- Ghodmode
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top