Boxhead
01-05-2004, 11:37 AM
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, 03: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, 03: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
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, 04: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, 10:23 PM
Something like this?
function changeIframe(page, tFrame, button){
var newPage = page;
var targetFrame = tFrame;
window.frames[targetFrame].location=newPage+"?param1=value1¶m2=value2";
var but = button;
buttonOver(but);
}
glenngv
01-06-2004, 03: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¶m2=value2";
buttonOver(button);
}
Boxhead
01-06-2004, 09: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, 09: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.