views:

70

answers:

3

Hi, I'm wondering, is it possible to collect the height of a specific div container from a separate page with JavaScript? I'm using jQuery btw and I'm in need of comparing heights of div containers.

Edit: To clarify a bit more, I load content from a specific div in a separate page using jQuery. This content is faded into a different container with dynamic height. But in the small fraction of time before the content arrives, it shrinks down to it's min-height.

What I've done so far is collecting the height of the container before and after the load. But it only works after I've loaded content once. Because I don't have the height before it's been loaded the first time.

+3  A: 
scunliffe
Yeah, it's not from a popup or nothing. Just from a separate page. Guess it can't be done since that page haven't even been rendered yet, thus you cannot collect any height since there is none :)
Kenny Bones
@Kenny - yeah it sounds like this fails on 2 counts. 1.) Security-wise you have no access to "some other page" that wasn't created by you, or that created you. 2.) If you did have access - you would need to get the height info after it rendered as it likely isn't correctly known until it has fully rendered.
scunliffe
A: 

Well, you can't get it until AFTER it's loaded via jQuery. Then you need to make sure you're not having a conflict between two divs with the same ID.

Khan
Yes, well strangely enough, after the first load, the loader loads the entire content of said div including the div itself. Resulting in a div with another div in it, both with the same ID. This actually happens in the original plugin as well. I haven't encountered any problems yet though.
Kenny Bones
A: 

From your comments it sounds like you are using ajax to load content from another page, you'll likely have the load div hidden... So I would position the loading div absolutely out of the viewport but not hidden. then get the height of your desired div but make sure you access it using the loading div and your desired div... something like this:

#divToLoadContent { position: absolute; left: -99999em; top: 0; } /* don't hide this div */

Script

var height = $('#divToLoadContent #myDesiredDiv').height();
fudgey