checking for a page section

J

javelin

I have inherited a project with some code that runs fine for some
frames but not for others. This is a frames based project, and
(apparently) sometimes there is a parent frame, and sometimes not. When
there is no parent frame, you see this error message:

'parent.frmUpper.document' is null or is not an object

I would like to know if there is a way to check for the existence of an
object by name so I can determine what to do next.

Thanks for suggestions.

J
 
M

Martin Honnen

javelin said:
I have inherited a project with some code that runs fine for some
frames but not for others. This is a frames based project, and
(apparently) sometimes there is a parent frame, and sometimes not. When
there is no parent frame, you see this error message:

'parent.frmUpper.document' is null or is not an object

I would like to know if there is a way to check for the existence of an
object by name so I can determine what to do next.

if (window != parent)
checks wether your code is run in frame window.
If you want to check for that particular frame sibling then do e.g.
if (parent.frames && parent.frames.frmUpper &&
parent.frames.frmUpper.document) {
// no access something in parent.frames.frmUpper.document
}
 
J

javelin

Thanks for the quick response, Martin. I may have asked the wrong
question. I tried checking wither or not the window was equal to
parent, and it still ran the next line, so I tried "if
(parent=='frmUpper')", and it did not run this code. I've tried other
screens that apparently required this code, and they work well enough,
but can you tell me if the code makes sense, or am I asking for
trouble?

Thanks again.
 
A

ASM

javelin a écrit :
I have inherited a project with some code that runs fine for some
frames but not for others. This is a frames based project, and
(apparently) sometimes there is a parent frame, and sometimes not. When
there is no parent frame, you see this error message:

'parent.frmUpper.document' is null or is not an object

could try :

function origine(what) {
what = parent.what? parent.what : self;
return what;
}

or :

function origine(what) {
return parent==self? window : parent.what;
}

origine('frmUpper').document;


(not tested)
 
J

javelin

Thanks so much for the response. I'm going to play with this to see
what results of it.
 
J

javelin

Using the "what" property did not work for me. I finally solved this
challenge by using a try/catch method. If the try fails, the catch does
nothing, and this works out perfectly.

Thanks for all the responses.
 
A

ASM

javelin a écrit :
Using the "what" property did not work for me.

this here works :

function origine(what) {
return parent==self? window : parent.frames[what];
}



(tested in Firefox)
 
J

javelin

Just getting back to this now. Yes, that did work. Thanks so very much.
javelin a écrit :
Using the "what" property did not work for me.

this here works :

function origine(what) {
return parent==self? window : parent.frames[what];
}



(tested in Firefox)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,431
Messages
2,571,678
Members
48,796
Latest member
Greg L.

Latest Threads

Top