...

View Full Version : pass url param to iframe



Boxhead
01-05-2004, 12:37 PM
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

Mhtml
01-05-2004, 04:50 PM
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* ..

Boxhead
01-05-2004, 04:57 PM
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

Kor
01-05-2004, 05:02 PM
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)

Boxhead
01-05-2004, 05:08 PM
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

Danne
01-05-2004, 11:23 PM
Something like this?



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

glenngv
01-06-2004, 04:41 AM
No need to create new variables here. Just use the function parameters directly.


function changeIframe(page, tFrame, button){
window.frames[tFrame].location=page+"?param1=value1&param2=value2";
buttonOver(button);
}

Boxhead
01-06-2004, 10:23 AM
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

glenngv
01-06-2004, 10:36 AM
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.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum