Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > Solution to find a frame by name in the frame hierarchy

Thread Tools

Solution to find a frame by name in the frame hierarchy

Daniel Frede
Posts: n/a
<script>try {
var frame1;
frame1=find('myFrameNameToFindInHierarchy',getFram e('myTopFrameName', window));
//Do something with the frame

}catch (e) {};

// Get frame by framename (recurse down)
function find(what,current) {
var ret;
for (var i=0;i<current.frames.length;i++) {
if (current.frames[i].name == what){
return current.frames[i];
ret = find(what,current.frames[i]);
return ret

// Get top frame by name (recurse up)
function getFrame(TopFrameName, currentWindow){
if ( == TopFrameName){
return currentWindow;
if ( =={
return getFrame(TopFrameName, currentWindow.opener);
} return getFrame(TopFrameName, currentWindow.parent);

Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Architecture name through hierarchy VHDL 6 04-03-2013 10:44 AM
How to find call hierarchy of a method Riyaz Java 5 08-07-2007 06:06 PM
Name conflict in class hierarchy Jeffrey Barish Python 8 05-23-2006 10:45 AM
frame hierarchy question... Mel Javascript 2 03-22-2005 07:03 AM
Proposed Image Hierarchy File Name Encoding Scheme Grant Robertson Digital Photography 1 05-13-2004 11:52 PM