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 9 of 9
  1. #1
    Regular Coder
    Join Date
    Dec 2003
    Location
    UK
    Posts
    106
    Thanks
    0
    Thanked 0 Times in 0 Posts

    pass url param to iframe

    I have a page with an Iframe which will contain dynamic content.

    the buttons on the page change the iframe page via a javascipt:

    <a href="#" onClick="changeIframe('about.asp', 'pages', 'about')"


    function changeIframe(page, tFrame, button){
    var newPage = page;
    var targetFrame = tFrame;
    window.frames[targetFrame].location=newPage;
    var but = button;
    buttonOver(but);
    }

    My question is how do I pass url variables to the page loading in the iFrame, I image I just replace the # with what I want but i couldnt get it to work.

    Cheers

    monkey

  • #2
    Senior Coder Mhtml's Avatar
    Join Date
    Jun 2002
    Location
    Sydney, Australia
    Posts
    3,531
    Thanks
    0
    Thanked 1 Time in 1 Post
    Firstly this is a javascript question, secondly I gather you mean a querystring? In which case you would want to send 'page.asp?what=this' .... If I read correctly what you were asking ...


    *moving thread* ..
    Omnis mico antequam dominus Spookster!

  • #3
    Regular Coder
    Join Date
    Dec 2003
    Location
    UK
    Posts
    106
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Sorry for the miss-post, I thought it was an iframe issue and therefore html.

    Anyway, cheers for the answer, I was being stupid and looking at the wrong thing!!

    monkey

  • #4
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts
    anyway, to pass a param to an iframe (for use it in a function on that iframe) use the reference

    top.frames[name].a_function(param)
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

  • #5
    Regular Coder
    Join Date
    Dec 2003
    Location
    UK
    Posts
    106
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I need the querystring in an sql statement to build a recordset, so I dont think your method will help me? but i may need it in the future anyway to cheers

    monkey

  • #6
    Regular Coder
    Join Date
    Aug 2002
    Location
    São Paulo, Brazil
    Posts
    367
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Something like this?

    PHP Code:
    function changeIframe(pagetFramebutton){
        var 
    newPage page;
        var 
    targetFrame tFrame;
        
    window.frames[targetFrame].location=newPage+"?param1=value1&param2=value2";
        var 
    but button;
        
    buttonOver(but);

    /Daniel

  • #7
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,048
    Thanks
    0
    Thanked 251 Times in 247 Posts
    No need to create new variables here. Just use the function parameters directly.
    Code:
    function changeIframe(page, tFrame, button){
        window.frames[tFrame].location=page+"?param1=value1&param2=value2";
        buttonOver(button);
    }

  • #8
    Regular Coder
    Join Date
    Dec 2003
    Location
    UK
    Posts
    106
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Ah! I see!

    This seems a lot more useful as I could add the params as variables in the function call!

    I created new vars here because I have seen it done this way - is this not neccessary/good protocol then?

    Cheers

    monkey

  • #9
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,048
    Thanks
    0
    Thanked 251 Times in 247 Posts
    function parameters are also local variables of the function.
    If you are going to modify the value of a parameter and at the same time use the original value, then you need to create a new local variable.


  •  

    Posting Permissions

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