Page 1 of 1
I-Frames and passing variables = pain in the arse!?
Posted: Mon Feb 28, 2005 10:42 am
by pthomas
I've pretty much wasted two days trying to pass variables to an I-frame. The initial passing the first time is no problem, all variables pass as they should. But when changes are made inside a form within that I-frame and the page inside the I-frame needs to be refreshed (called via the form) it not only gets the new GET values, but it also gets the old GET values passed to it as well.
Its as if the main page will re-pass the original GET values into the I-frame each time the I-frame refreshes itself.
Here's how its setup, The parent page grabs its needed variables out of the POST and then does what it needs to and passes different variables via GET to its child I-frame. That I frame has some user customizable options that after those are set and the user clicks update, the child I-frame will refresh itself with the changes, grabbing the GET values it passed back to itself.
Any ideas or am I just totally over looking something here?
Paul
Posted: Mon Feb 28, 2005 10:50 am
by CoderGoblin
Please give some example code.
I would guess you are outputting the frame without passing the parameters correctly (Call the iframe before processing the POST values or somesuch). In mozilla try a View Frame Info on the Iframe to check the parameters passed.
It should be feasable without too much trouble.
Posted: Mon Feb 28, 2005 11:05 am
by pthomas
Unfortunatley I found out I was taking too long on getting my code to work with I frames, so we scrapped the i-frame and are using a floating table.
What I'd like to know is with I-frames, if you refresh the child frame does old POST/GET data that the parent frame originally passed to the child i-frame get passed again to the refreshed child i-frame?
thanks,
Paul
Posted: Mon Feb 28, 2005 11:09 am
by feyd
if anything, only the get data, as that was in the iframe's original url (which if you didn't update the parent would still be existing)
Posted: Mon Feb 28, 2005 11:13 am
by pthomas
Ok, that's what I was seeing, the I frames original URL still had on the old GET data. How do I reset the parent for future use so that it doesn't pass the old GET data?
Paul
Posted: Mon Feb 28, 2005 11:19 am
by feyd
you either rebuild the containing page such that it doesn't contain the old get data (when needed) .. or use an entirely differing method to passing the data.
Personally, I'd suggest avoiding iframes as they add far too many headaches for their "benefit."

Posted: Mon Feb 28, 2005 11:27 am
by pthomas
Personally, I'd suggest avoiding iframes as they add far too many headaches for their "benefit."
I was kinda hoping to hear someone say that, my experience with them since last thursday (part of my weekend too) hasn't been all that good.
How would I rebuild the parent page? Are you suggessting to re-code it or refresh it a certain way?
thanks,
Paul
Posted: Mon Feb 28, 2005 11:32 am
by feyd
refresh.
Posted: Tue Mar 01, 2005 5:29 am
by CoderGoblin
I have had several situation where IFrames perform functionality which would not easily be possible otherwise. Notably where you have a complex page which you do not want to reload as data is static apart from a very small section. If well thought out before hand this is not a problem.
Posted: Tue Mar 01, 2005 7:28 am
by pthomas
I can see where they would be useful, but I just couldn't get it working in time. Like I said, the problem that I was having was that the original page that has the i-frame inside of it kept passing the original GET data to the i-frame everytimg the I-frame would refresh itself. So I'd get extra data in the URL passed to the I-frame that should not be there resulting in my functions getting wrong data.
I must mention though that after some further looking over my old code, I think that the way I called the I-frame may have had something to do with my problems. The parent frame would call the I-frame with get data appended directly to the URL. For instance, the page submit.php would be called like:
Code: Select all
submit.php?quї0]=23&quї1]=15&en=2&po=97&mi=45
instead of how I would pass data by using a few <input type=hidden .....> tags. But I couldn't figure any other way to take the data that was passed to the parent frame and pass it onto the child (i-frame) without user interaction needed. My guess was that everytime the i-frame would refresh to update data, the old URL was appended on.
Paul
Posted: Tue Mar 01, 2005 7:37 am
by n00b Saibot
try to put some if-else logic or change the way data is parsed in the iframe knowing that the url is always appended to...
Posted: Tue Mar 01, 2005 7:48 am
by CoderGoblin
Normally when I use an IFRAME I have an href link targeting the iframe which passes the correct information. As can be said to most things coding wise, keep it simple and you will not have too many complications.
Judging from your comments another possible solution would be to use session variables to hold most of the "static" values, with only changable values being passed through to the IFrame.