473,403 Members | 2,222 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,403 software developers and data experts.

Getting the width of a frame

JJ
I'm working with a web site that has frames defined as:

<frameset rows="60,*" frameborder="yes" border="0" framespacing="0" cols="*"
bordercolor="#eeeeee" topmargin="0" leftmargin="0" marginheight="0"
marginwidth="0">
<frame name="topFrame" scrolling="auto" src="top.asp"
bordercolor="#cccc66" frameborder="yes" topmargin="0" leftmargin="0"
marginheight="0" marginwidth="0" framespacing="0">
<frameset cols="180,*" frameborder="YES" border="0" framespacing="2"
rows="*" bordercolor="#eeeeee" resize="yes" topmargin="0" leftmargin="0"
marginheight="0" marginwidth="0">
<frame name="leftFrame" scrolling="auto" src="left.asp"
bordercolor="#eeeeee" frameborder="no">
<frame name="basefrm" src="common/DisplayInformation.asp"
scrolling="auto" bordercolor="#eeeeee" frameborder="no">
</frameset>
</frameset>

I need to get the width of "leftFrame" from a script running in one of the
other frames (usually "basefrm").

I tried parent.leftFrame.width, but it returns "undefined" (but
parent.leftFrame.name does return "leftFrame"). I suspect I need something
before ".leftFrame", since the framesets are nested. How would I refer to
leftFrame to get its width?


Jul 23 '05 #1
4 6269
In article <yI********************@comcast.com>, jj@nospam.com enlightened us
with...

I need to get the width of "leftFrame" from a script running in one of the
other frames (usually "basefrm").

I tried parent.leftFrame.width, but it returns "undefined" (but
parent.leftFrame.name does return "leftFrame"). I suspect I need something
before ".leftFrame", since the framesets are nested. How would I refer to
leftFrame to get its width?

A frame is a window object. There is no such thing as window.width.
http://www.devguru.com/Technologies/...ef/window.html <


As to how to reference the frame from a frameset, assuming your frameset is
always the main frameset and isn't contained in someone else's, you can use
top.frames["framename"] or top.frames[index] to reference one of the frames
or a nested frame.
The way you referenced it is fine, too. If you got the name, you got it.
But there is no width of a window. Netscape uses window.innerWidth. IE uses
document.body.offsetWidth. I can't say for other browsers.

This worked for me. Tested in IE6 / NN7.

<script type="text/javascript">
function checkIt()
{
var w = top.frames[1].window;
if (w.innerWidth) alert(w.innerWidth);
else if (w.document.body.offsetWidth) alert(w.document.body.offsetWidth);
else alert("no clue.");
}
</script>

--
--
~kaeli~
Santa's helpers are subordinate clauses.
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace

Jul 23 '05 #2
JJ
Before you replied I found another post that had some information and I
tried this and it worked:

top.document.all.leftFrame.width;

I know the window object does not have a width attribute, but according to
this:

http://msdn.microsoft.com/library/de...ects/frame.asp

the frame object does have a "width" attribute.

"kaeli" <ti******@NOSPAM.comcast.net> wrote in message
news:MP************************@nntp.lucent.com...
In article <yI********************@comcast.com>, jj@nospam.com enlightened us with...

I need to get the width of "leftFrame" from a script running in one of the other frames (usually "basefrm").

I tried parent.leftFrame.width, but it returns "undefined" (but
parent.leftFrame.name does return "leftFrame"). I suspect I need something before ".leftFrame", since the framesets are nested. How would I refer to leftFrame to get its width?

A frame is a window object. There is no such thing as window.width.
http://www.devguru.com/Technologies/...ef/window.html <


As to how to reference the frame from a frameset, assuming your frameset

is always the main frameset and isn't contained in someone else's, you can use top.frames["framename"] or top.frames[index] to reference one of the frames or a nested frame.
The way you referenced it is fine, too. If you got the name, you got it.
But there is no width of a window. Netscape uses window.innerWidth. IE uses document.body.offsetWidth. I can't say for other browsers.

This worked for me. Tested in IE6 / NN7.

<script type="text/javascript">
function checkIt()
{
var w = top.frames[1].window;
if (w.innerWidth) alert(w.innerWidth);
else if (w.document.body.offsetWidth) alert(w.document.body.offsetWidth);
else alert("no clue.");
}
</script>

--
--
~kaeli~
Santa's helpers are subordinate clauses.
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace

Jul 23 '05 #3
In article <y4********************@comcast.com>, jj@nospam.com enlightened us
with...
Before you replied I found another post that had some information and I
tried this and it worked:

top.document.all.leftFrame.width;

I know the window object does not have a width attribute, but according to
this:

http://msdn.microsoft.com/library/de...ects/frame.asp

the frame object does have a "width" attribute.


I hope you only have to support IE. ;)

Glad you found a solution.
--
--
~kaeli~
With her marriage, she got a new name and a dress.
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace

Jul 23 '05 #4
JJ
Unfortunately, in this case, it does only need to support IE. It's not
really a publicly accessible web site, and parts of it use ActiveX controls.

(Even though we only support IE, I try to write everything I do so it
supports other browsers also, to the extent that I can.)
"kaeli" <ti******@NOSPAM.comcast.net> wrote in message
news:MP************************@nntp.lucent.com...
In article <y4********************@comcast.com>, jj@nospam.com enlightened us with...
Before you replied I found another post that had some information and I
tried this and it worked:

top.document.all.leftFrame.width;

I know the window object does not have a width attribute, but according to this:

http://msdn.microsoft.com/library/de...ects/frame.asp
the frame object does have a "width" attribute.


I hope you only have to support IE. ;)

Glad you found a solution.
--
--
~kaeli~
With her marriage, she got a new name and a dress.
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace

Jul 23 '05 #5

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

Similar topics

7
by: Jane Austine | last post by:
As you add more items, say text lines, in Text widget, it gets too slow and almost impractical to use on. Take idle for example. If the text gets bigger(e.g. print...
3
by: N. Demos | last post by:
I have a single row table with fixed dimensioned cells nested inside a fixed dimensioned div, which has overflow: hidden. The div's dimensions are such that It should only display the first two...
4
by: WH | last post by:
While the whidth of the table can be set as 80%, the size of the iframe can not be changed once set. I am looking for a solution which the iframe's width can be set according to the...
3
by: coolsti | last post by:
I need some help here. I am making an application which allows a user to look at a series of picture files one at a time, and enter the outcome of various visual tests to a database. The...
8
by: Dave Cook | last post by:
Hi I would like to create a table that uses the whole width of IE. I have set the table width to 100% and the right margin to 0 on the document but still the table is displayed about 50 pixels...
2
by: panos100m | last post by:
Hi there I am using a menu frame on the left side but i cant destroy it using the logout link that i created ... any ideas? //index.php // PAGE this will just redirect to the...
9
dmjpro
by: dmjpro | last post by:
Suppose i have a HTML file like this.... <frameset rows="10%,*"> <frame name="frame1" src="page1"/> <frame name="frame2" src="page2"/> </frameset> Now my page1 is like this ..
1
by: pankaj17 | last post by:
hello, I want to find out the height and width of right frame in iframe that is included in left frame. main.html <html> <frameset cols="15%, *" id="fs1"> <frame src="left.html" name="left"...
2
mrjohn
by: mrjohn | last post by:
Hey, I'm trying to make a program that will recognize when certain keys are released, so that I can encorperate it into a game I'm making. Unfortunately, it doesn't seem to be working. When I run the...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
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,...
0
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...
0
jinu1996
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...
0
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.