Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 8 of 8
  1. #1
    New Coder
    Join Date
    Jun 2003
    Location
    Miami
    Posts
    33
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Question Frame Name to "string var"

    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?

  • #2
    Regular Coder
    Join Date
    Aug 2002
    Location
    São Paulo, Brazil
    Posts
    367
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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?
    /Daniel

  • #3
    New Coder
    Join Date
    Jun 2003
    Location
    Miami
    Posts
    33
    Thanks
    1
    Thanked 0 Times in 0 Posts
    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.

  • #4
    Regular Coder
    Join Date
    Aug 2002
    Location
    São Paulo, Brazil
    Posts
    367
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Pass the window from the frame as a parameter:

    Code:
    function functionName(frame) {
        // Processing
        frame.document.write(result);
    }
    I assume that maybe you want to avoid that, but I don't know if there's another way.
    /Daniel

  • #5
    New Coder
    Join Date
    Jun 2003
    Location
    Miami
    Posts
    33
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Arrow

    Testing it out, back to you shortly

  • #6
    New Coder
    Join Date
    Jun 2003
    Location
    Miami
    Posts
    33
    Thanks
    1
    Thanked 0 Times in 0 Posts
    This is not getting across:

    Pass the window from the frame as a parameter:
    s/b
    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.

  • #7
    Regular Coder
    Join Date
    Aug 2002
    Location
    São Paulo, Brazil
    Posts
    367
    Thanks
    0
    Thanked 0 Times in 0 Posts
    That's what I thought. If you pass the window from the frames as parameter:
    top.functionName(window);
    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.
    top.functionName("frameName");
    /Daniel

  • #8
    New Coder
    Join Date
    Jun 2003
    Location
    Miami
    Posts
    33
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Cool

    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;


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •