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

Getting Height and Width from parent window

Status
Not open for further replies.

tmcneil

Technical User
Nov 17, 2000
294
US
I have this javascript function which is part of the subModal DHTML code you can get off the web,
The js function grabs the height and width of the parent window in order to place a popup window over the web page. The popup window mimics the showModalDialog(), which is fine in IE, but is not really modal in FF. This subModal is a new twist that makes it modal in FF, using a div and setting a mask over the parent window.

Well, my web pages are built using frames, so the parent window is like the workspace area. So, when the subModal appears (by clicking on a button on the page), it turns off access to all elements in the workspace, but not elements, like tabs that are outside of the parent window. The web page has a heirarchy to it, so I would like to grab the height and width of the entire window or windows, not just the parent window. Any ideas?

Code:
/**
 * Sets the size of the popup mask.
 *
 */
function setMaskSize()
{
	var theBody = document.getElementsByTagName("BODY")[0];
			
	var fullHeight = getViewportHeight();
	var fullWidth = getViewportWidth();
	alert("fullHeight: " + fullHeight + ", fullWidth: " + fullWidth);
	
	// Determine what's bigger, scrollHeight or fullHeight / width
	if (fullHeight > theBody.scrollHeight)
	{
		popHeight = fullHeight;
	}
	else 
	{
		popHeight = theBody.scrollHeight;
	}
	
	if (fullWidth > theBody.scrollWidth)
	{
		popWidth = fullWidth;
	} 
	else
	{
		popWidth = theBody.scrollWidth;
	}
	
	gPopupMask.style.height = popHeight + "px";
	gPopupMask.style.width = popWidth + "px";
}

Thanks,
Todd
 
While this is a quick and not very well researched answer, it's a gut feeling / hunch... and that is that you will not be able to disable elements outside frames that you control (i.e. tabs, chrome, etc).

Hope this helps,
Dan



Coedit Limited - Delivering standards compliant, accessible web solutions

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
Dan,

Well, the key in some of this code is that it uses this:
Code:
theBody = document.getElementsByTagName('BODY')[0];

It's getting the body of the document, so I'm thinking I could do something to the equivalent of this. The js code adds the div onto the body of the chosen html page. So, I am working on getting the document body of the topmost page and see if I can work from there. I found out how to get the height and width of the top document. There are two different ways:
Code:
var fullHeight = window.top.frames['top'].innerHeight;
var fullWidth = window.top.frames['top'].innerWidth;
or
Code:
var fullHeight = window.top.document.body.offsetHeight;
var fullWidth = window.top.document.body.offsetWidth;

it took while to find some of this. So, I'll keep plugging away on it.

Todd
 
Dan,

We've abandoned this approach as it created too many headaches. So we are trying another way.

Todd
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top