• Passing a Variable to FRAME

    Author
    Topic
    #356234

    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

    Viewing 1 reply thread
    Author
    Replies
    • #526949

      Spotted this at Codebelly – not sure if it is exactly what you want but might give you some clues.

      • #527461

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

        Thanks for replying.

        Ade

    • #526959

      I do it all the time here with our popups. View Source and study the code.

      • #527462

        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…

        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

        • #527512

          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.

          • #527688

            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 ‘name’ 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 “”
            *****

            Sub window_onload()
            window.frames(“main”).location.href = “staff/” + name + “.htm”
            End sub

            <frame NAME=”main” SRC=”” SCROLLING=”no” NORESIZE TARGET=”topl”>

            etc
            etc
            etc

            • #527725

              Brilliant sleuthing. I’ve salted your solution away with the rest of my cut-n-paste collection.

        • #527578

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

          • #527687

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

            Thanks for your help.

            Ade

    Viewing 1 reply thread
    Reply To: Passing a Variable to FRAME

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: