View Full Version : Frame Name to "string var"

07-15-2003, 06:40 PM
Some of my JS scripts require that I state the frame where the code originated from, like:

top.PanelTop.location='javascript: parent.'+inFrame+'.JS_var';

inFrame = the referring frame

I can't figure out the command to give me the inframe "string" from the script, so have to type it in. Problem is when the script runs from different frames..

I have tried:
inframe=self | _self | .self (which returns [object])
inframe=self.location (returns file & path name)
I have also tried versions of eval(self)

I would put an "inframe=" var in each file that needs it, , but ideally I would like to use inframe=parent."framename" in the js, making the use more dynamic.

So, is there not a command or functions that returns the sting name of a Frame?

07-15-2003, 06:52 PM
I'm not sure what you are trying to do.

Do you want to change the location of your top frame with the one in the current frame?

Or do you simply want to call a function located in another frame?

07-15-2003, 07:06 PM
My javascript requires that I identify which Frame the script came from.

The result is usually used in writing to a different frame, but where it is going is not the question. The questions is:

How do I assign a frame name to a var automaticly, without typing it in

Reason: the code that calls the function is sometimes in different frames and needs to state its framename.

07-15-2003, 07:21 PM
Pass the window from the frame as a parameter:

function functionName(frame) {
// Processing

I assume that maybe you want to avoid that, but I don't know if there's another way.

07-15-2003, 07:25 PM
Testing it out, back to you shortly :)

07-15-2003, 07:51 PM
This is not getting across:

Pass the window from the frame as a parameter:
Assign Current or Parent frame "name" to string variable

Once I have the name in a variable I can manipulate it.

Note: the same code is used on different pages, in different frames, and I just simply have to identify the frame, dynamically.

07-15-2003, 08:03 PM
That's what I thought. If you pass the window from the frames as parameter:
you only need the framename to manipulate the frame element in the top frame, like changing height of it.
If you don't need the manipulate it - only write to it, the window parameter should be enough.

Another way is of course to simply pass the name of the frame.

07-15-2003, 08:19 PM
Danne, I appreciate your help, but you still did not answer or recognize the basic question:

How to assign a frame name to a variable.

The answer is:

var inframe=self.name;