Results 1 to 11 of 11
  1. #1
    2 Star Lounger
    Join Date
    Jan 2001
    Location
    Edinburgh, Midlothian, Scotland
    Posts
    144
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Passing a Variable to FRAME

    Can anyone help me with trying to pass a J(ava)Script variable to an HTML frames page.

    I have a JScript function (called from my home page) that opens a frames page in a popup window (using window.open). I want to pass the variable (from the JScript function) to the popup frames page and use the variable to specify the html page that should be loaded into one of the frames.

    i.e. Hyperlink (java script:Staff('jsmith') from home page, runs JavaScript function Staff(name). Staff(name) opens frames page in popup window (using window.open) and passes to it the name variable 'jsmith'. Javascript function in frames page HEAD adds ".htm" to name variable and sets it to MyVar (which now equals 'jsmith.htm'). I now want to put the MyVar variable into the FRAME SRC element and hence get the page jsmith.htm to load in the particular frame.

    Am I making life difficult for myself, or is this possible? I use Frontpage 2k for my design, so my knowledge of HTML isn't brilliant(!); but I know VbScript and VBA well, and J(ava)Script will always be a struggle!!

    Obviously, the idea is to re-use the Staff(name) function elsewhere to open up different staff profiles.

    Any help or pointers would be gratefully appreciated...

    Thanks in advance,

    Ade

  2. #2
    Plutonium Lounger Leif's Avatar
    Join Date
    Dec 2000
    Location
    U.K.
    Posts
    14,010
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Passing a Variable to FRAME

    Spotted this at <A target="_blank" HREF=http://www.codebelly.com/>Codebelly</A> - not sure if it is exactly what you want but might give you some clues.

  3. #3
    Silver Lounger
    Join Date
    Dec 2000
    Location
    Los Angeles, California, USA
    Posts
    1,734
    Thanks
    0
    Thanked 3 Times in 1 Post

    Re: Passing a Variable to FRAME

    I do it all the time here with our popups. View Source and study the code.
    <IMG SRC=http://www.wopr.com/w3tuserpics/Eileen_sig.gif>

  4. #4
    2 Star Lounger
    Join Date
    Jan 2001
    Location
    Edinburgh, Midlothian, Scotland
    Posts
    144
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Passing a Variable to FRAME

    Thanks for the site - some great little gems that I will investigate further. Still struggling though (see my other response).

    Thanks for replying.

    Ade

  5. #5
    2 Star Lounger
    Join Date
    Jan 2001
    Location
    Edinburgh, Midlothian, Scotland
    Posts
    144
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Passing a Variable to FRAME

    Nope, still don't get it. Studied your code, followed through the javascript..but can't see how I can get my variable into the SRC of FRAME?? This is what I've got...

    <frame NAME="main" SRC="Staff/ + myVar + " SCROLLING="no" NORESIZE TARGET="topl">

    I know for sure that myVar = ade.htm, I've tested it with a alert window. But when the window opens, the frame in question says it can't find the file etc etc.

    Just don't get it? Am I getting my commas and +'s in the wrong place??

    Thanks in advance,

    Ade

  6. #6
    Silver Lounger
    Join Date
    Dec 2000
    Location
    Los Angeles, California, USA
    Posts
    1,734
    Thanks
    0
    Thanked 3 Times in 1 Post

    Re: Passing a Variable to FRAME

    I'm not much use working from scratch. What I do is find something that's already doing approximately what I want, and work from there.
    <IMG SRC=http://www.wopr.com/w3tuserpics/Eileen_sig.gif>

  7. #7
    Plutonium Lounger Leif's Avatar
    Join Date
    Dec 2000
    Location
    U.K.
    Posts
    14,010
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Passing a Variable to FRAME

    Not that I really know what I'm taklking about, but shouldn't only the
    Staff/
    be in quotes?
    i.e. SRC="Staff/" + myVar ....

  8. #8
    2 Star Lounger
    Join Date
    Jan 2001
    Location
    Edinburgh, Midlothian, Scotland
    Posts
    144
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Passing a Variable to FRAME

    Sorry, no joy with all variations of quotes. Have managed to solve the problem though. See other post.

    Thanks for your help.

    Ade

  9. #9
    2 Star Lounger
    Join Date
    Jan 2001
    Location
    Edinburgh, Midlothian, Scotland
    Posts
    144
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Passing a Variable to FRAME

    Solved it!

    Had a search around Microsoft Supprt KB (specifically Internet Explorer Programming) and noted a few pointers. Basically, I've ended up specifying a VBScript onload event to set the source of the frame I'm interested in.

    The solution is below for anyone who's interested...

    Thanks for all the pointers.

    Ade

    *****
    Variable <font color=blue>'name'</font color=blue> is passed to page by javascript function Staff('name'), which itself opens the popup page window we're dealing with below.

    Set SRC for the frame specified in VBScript to ""
    *****

    <head>
    <SCRIPT LANGUAGE="VBScript">
    Sub window_onload()
    window.frames(<font color=red>"main"</font color=red>).location.href = "staff/" + <font color=blue>name</font color=blue> + ".htm"
    End sub
    </SCRIPT>
    </head>

    <frameset FRAMESPACING="0" BORDER="0" rows="*,8%" FRAMEBORDER="0">
    <frameset cols="*,79%">
    <frame NAME="contents" src="contents.htm" SCROLLING="yes" NORESIZE TARGET="main">
    <frame <font color=red>NAME="main"</font color=red> SRC="" SCROLLING="no" NORESIZE TARGET="topl">

    etc
    etc
    etc

  10. #10
    Plutonium Lounger Leif's Avatar
    Join Date
    Dec 2000
    Location
    U.K.
    Posts
    14,010
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Passing a Variable to FRAME

    Thanks for posting your solution <img src=/S/thumbup.gif border=0 alt=thumbup width=15 height=15>

  11. #11
    Silver Lounger
    Join Date
    Dec 2000
    Location
    Los Angeles, California, USA
    Posts
    1,734
    Thanks
    0
    Thanked 3 Times in 1 Post

    Re: Passing a Variable to FRAME

    Brilliant sleuthing. I've salted your solution away with the rest of my cut-n-paste collection.
    <IMG SRC=http://www.wopr.com/w3tuserpics/Eileen_sig.gif>

Posting Permissions

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