473,397 Members | 2,099 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,397 software developers and data experts.

retrieve the location of a page in a frame

Fre
Hi, i made script with an alert window that should show me the location of
the page in frame CONTENT (..../artikels.aspx).
But it don't work, i got an error: 'top.frames.1.frames' is empty or nog an
object.

When i try with: alert(top.location)
i get the location of my index page, that works, but when i use the frame
arrays nothing works

Here is my code:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN"
"http://www.w3.org/TR/html4/frameset.dtd">
<html>
<head>
<TITLE>My Title</TITLE>
<script>
alert(top.frames[1].frames[1].frames[0].location);
</script>
</head>
<frameset cols="*,765,*" frameborder="no" border="0" framespacing="0">
<frame name="left" noresize src="bgframe.htm">
<frameset rows="111,*" cols="*" frameborder="NO" border="0"
framespacing="0">
<frame name="head" src="header.htm" noresize scrolling="no">
<frameset cols="*,200" frameborder="NO" border="0" framespacing="0">
<frame name="content" src="artikels.aspx" scrolling="yes">
<frame name="menu" src="menu.aspx" noresize scrolling="no">
</frameset>
</frameset>
<frame name="right" noresize src="bgframe.htm">
</frameset>
<noframes>
<body>
<p>This page uses frames, but your browser doesn't support them.</p>
</body>
</noframes>
</html>


Thx in advance!
Frederik
Jul 23 '05 #1
4 1951
On Sat, 17 Apr 2004 18:51:40 GMT, Fre
<fr*****************************@howest.be> wrote:
Hi, i made script with an alert window that should show me the location
of the page in frame CONTENT (..../artikels.aspx). But it don't work, i
got an error: 'top.frames.1.frames' is empty or nog an object.

When i try with: alert(top.location)
i get the location of my index page, that works, but when i use the
frame arrays nothing works

Here is my code:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN"
"http://www.w3.org/TR/html4/frameset.dtd">
<html>
<head>
<TITLE>My Title</TITLE>
<script>
The type attribute is required. This should read

<script type="text/javascript">
alert(top.frames[1].frames[1].frames[0].location);
</script>


At this point, the browser hasn't begun reading the frame and frameset
elements below, so the frames collection is empty. Either place the script
element below the closing frameset tag, or execute the script "onload".

[snipped frameset HTML]

You should really aim to avoid frames. CSS navigation menus are preferable.

Mike

--
Michael Winter
M.******@blueyonder.co.invalid (replace ".invalid" with ".uk" to reply)
Jul 23 '05 #2
Fre
Now the code is error free, but i don't get an alertbox?

Thx for reaction Mike!

Frederik
Jul 23 '05 #3
On Sat, 17 Apr 2004 20:43:29 GMT, Fre
<fr*****************************@howest.be> wrote:
Now the code is error free, but i don't get an alertbox?


This is probably what you're after. The frames collection contains all of
the frames in a window, not per frameset. That means that "left" is frame
0, "head" is frame 1, "content" is frame 2, "menu" is frame 3, and "right"
is frame 4.

I took the liberty to make your sample validate (see
<URL:http://validator.w3.org/>).

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN"
"http://www.w3.org/TR/html4/frameset.dtd">

<html>
<head>
<meta http-equiv="Content-Type"
content="text/html; charset=iso-8859-1">

<title>My Title</title>

<script type="text/javascript">
function displayFrameSrc( idx ) {
alert( frames[ idx ].location.href );
}
</script>
</head>

<frameset cols="*,765,*" onload="displayFrameSrc(2)">
<frame name="left" noresize src="bgframe.htm" frameborder="0">
<frameset rows="111,*" cols="*">
<frame name="head" src="header.htm" noresize scrolling="no"
frameborder="0">
<frameset cols="*,200">
<frame name="content" src="artikels.aspx" scrolling="yes"
frameborder="0">
<frame name="menu" src="menu.aspx" noresize scrolling="no"
frameborder="0">
</frameset>
</frameset>
<frame name="right" noresize src="bgframe.htm" frameborder="0">
<noframes>
<body>
<p>
This page uses frames, but your browser doesn't support them.
</p>
</body>
</noframes>
</frameset>
</html>

--
Michael Winter
M.******@blueyonder.co.invalid (replace ".invalid" with ".uk" to reply)
Jul 23 '05 #4
Fre
Thank you very much Mike to take time solving my problem!
Since you told me that the frames collection contains all of the frames in a
window i understand it perfect now.
I've read many forums before this post and there i've read some articles
with the use of this scriptline:
top.frames[1].frames[0].location (forum i visited for this script:
http://www.asp.net/Forums/ShowPost.a...&PostID=507978)

In the past i worked already with css for some of my school projects but for
this one i started working with frames (don't ask why :) but this is the
last time i do it this way)

Greetz Frederik

"Michael Winter" <M.******@blueyonder.co.invalid> schreef in bericht
news:op**************@news-text.blueyonder.co.uk...
On Sat, 17 Apr 2004 20:43:29 GMT, Fre
<fr*****************************@howest.be> wrote:
Now the code is error free, but i don't get an alertbox?
This is probably what you're after. The frames collection contains all of
the frames in a window, not per frameset. That means that "left" is frame
0, "head" is frame 1, "content" is frame 2, "menu" is frame 3, and "right"
is frame 4.

.... Michael Winter
M.******@blueyonder.co.invalid (replace ".invalid" with ".uk" to reply)

Jul 23 '05 #5

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

Similar topics

10
by: Scott | last post by:
I'm new to ASP, but I've been programming in VB for several years, and I'm having a few issues with this ASP enhancement I'm working on. I've found ASP to be a lot different than what I'm use to...
1
by: Funk | last post by:
Hi, I am currently creating a system that will support web based research. The idea is that the researcher is able to use Internet Explorer or Mozilla, or whichever browser to search for...
1
by: Georgios Zakitraxis | last post by:
Hi, i have frames. I want to retrieve from a page in frame 1 the pagename of the page in frame 2 That should be possible with javascript, but I don't know how to. Suggestions, Hints, did...
10
by: Roland | last post by:
Hello, the example code is the following(the number in parentheses at the beginning are just for reference)(The complete HTML file is at the end of this article): (1)window.location =...
1
by: Andrew Poulos | last post by:
I've got a simple navigation system set up in a framed site: navigation/top frame and a main body frame. Whenever you click on a navigation button it passes the new location to this function: ...
4
by: andreas.w.h.k. :-\) | last post by:
How do I change the address location in the wsdl <wsdl:port name="SearchSoap12" binding="tns:SearchSoap12"> <soap12:address location="http://searchservices/engine/search.asmx" /> </wsdl:port> ...
2
by: PopeLando | last post by:
I have a function that checks to see if we are in frames, and if we are, sets mainFrame location to the new url. What happens is, when you click the link that calls the function, (which is in a page...
4
by: Matt | last post by:
I am no JavaScript guru so please bear with me and be as detailed as possible with your response. I thank you in advance. I have an ASP page that contains form elements. I also have an inline...
1
by: michal.podlewski | last post by:
Hi All, I have a problem with a simple (as I thought till now) thing: I want to make a link in a child-window which would change site in the parent-window and along with closing child window. 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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.