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

What frame a page is in

How can a page know which frame in a frameset it is in?

Andrew Poulos
Jul 23 '05 #1
4 1326


Andrew Poulos wrote:
How can a page know which frame in a frameset it is in?


window.name
gives you the name of the window or frame thus whatever.html when loaded in
<frame name="frameName" src="whatever.html">
can check
if (window.name == 'frameName')
That obviously does not help with unnamed frames but then you would need
to walk the frames and compare each to window to find out which frame
you are in.
--

Martin Honnen
http://JavaScript.FAQTs.com/
Jul 23 '05 #2
VK
You did not say where your script is: in the frameset or in an inner
frame.
For inner frames could be:

function whereIAm() {
var tmp = null;
for (i=0;i<window.top.frames.length;i++) {
if (window.top.frames[i] === self) {
tmp = window.top.frames[i];
break;
}
}
return tmp;
}

If you are using nested framesets (I hope not :-), then you need to use
recursive calls checking if (window.top.frames[i].frames) != 0

Jul 23 '05 #3
>> How can a page know which frame in a frameset it is in?


window.name
gives you the name of the window or frame thus whatever.html when loaded in
<frame name="frameName" src="whatever.html">
can check
if (window.name == 'frameName')
That obviously does not help with unnamed frames but then you would need
to walk the frames and compare each to window to find out which frame
you are in.


If the frames are unnamed and I do a comparison, say,
window.frames[1].location == self.location
that would "fail" if the same page was loaded into more than one frame.

So does that mean that in some situations the page can't know what frame
it's in?

Andrew Poulos

Jul 23 '05 #4


Andrew Poulos wrote:
If the frames are unnamed and I do a comparison, say,
window.frames[1].location == self.location
that would "fail" if the same page was loaded into more than one frame.


There is no need to compare the location, you should compare the objects
e.g.
parent.frames[1] == window

--

Martin Honnen
http://JavaScript.FAQTs.com/
Jul 23 '05 #5

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

Similar topics

1
by: Julius Mong | last post by:
Dear all, I have the following: <html> <head> .... </head> <frameset ...> <frame .../> <frameset name="page" rows="60,*" ...> <frame src='top.html' .../>
3
by: Morten Thorsen | last post by:
Hi frame experts c",) Hope you can help me out on this one I've got a frameset (index.html) on my server (server A) defining two frames. Left frame is named "menu" and contains a page (menu.html)...
5
by: Frame | last post by:
I'm looking for tutorials or articles considering HTML Frames and how to handle them with Javascript. E.g. samples how Frames can exchange information, can a Frame instruct other Frame to update...
3
by: Jim Cobban | last post by:
I have a set of web pages that are organized in pairs. One of each pair contains a graphic and the other is an extended description of the graphic. I am trying to set it up that selecting a single...
8
by: moondaddy | last post by:
Are frame pages really taboo in asp.net and if so, why and what's the down side of using them? I'm trying to use user controls instead, but it seems that a lot of things were a lot easier with...
3
by: qwerty | last post by:
I´m new to ASP.Net. My workmate has some experience with it. He claimed that in ASP.Net working with frames is much simpler than it was ASP. I asked explanation but he couldn't give me such. (a...
5
by: Martin Chen | last post by:
I have a frame set (as per MS FrontPage 2000). It has a contents and a main frame. The contents frame has a menu bar written with with javascript (in the context of a table). In IE6.1 everything...
17
by: Bruno | last post by:
I have a feature that is hosted on a different domain from the primary one in a frame, and need to retain values in a cookie. example: A web page at one.com contains a frame which has a page...
2
by: mrjoka | last post by:
hi experts, i'm developing a page in ASP but i'm doing also some javascript insode the page. i'm creating a frame and i want to loop this frame with a duplicateloop function so the form will be...
3
by: rajarya | last post by:
Hi, I m designing a HTML page(index.html),here i have 2 frames,by defult both frames have index1.html and index2.html as their source . in first frame(index.html) ,i have some redio buttons,and a...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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:
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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
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.