weemikey Posted July 24, 2007 Share Posted July 24, 2007 Hi all. So I'm working on a project with a guy. I have logic in php that displays in an iframe. The iframe is defined on an html page called index.php. When we go to, for example, a specific member's page, we want the logic to put the member's name in a DIV also defined in index.php. My idea was this: In display_member.php before anything other than a query to get the display name I want to make a call header("location:index.php?display_name=$display_name"); The stab in the dark was that the "outside" of my page would refresh, showing the newly passed in value while STILL showing the member's data in the contained iframe. Does that make sense? Then I have a $_GET on index.php that looks for $display_name and puts that up onscreen on the main "framing" page. Any bright ideas for how this might work? If it's a totally different idea that's fine as well! Thanks, Mike Quote Link to comment Share on other sites More sharing options...
btherl Posted July 24, 2007 Share Posted July 24, 2007 If you are trying to refresh the page without refreshing the iframe, then no that is not possible. An iframe is "part of" the main page. But I see no reason why you cannot use the location header early to abort the current page processing, and redirect to the alternate page which has everything you want. btw, relative "location" headers are not standard, so it's safer to give a full url instead (you can extract the correct url from $_SERVER variables). Another option you may consider is using javascript to edit the div and put the name there. Javascript can edit any virtually any part of a page without requiring a reload. Quote Link to comment Share on other sites More sharing options...
weemikey Posted July 24, 2007 Author Share Posted July 24, 2007 Thanks for the reply. I'm still stumped. I see examples of javascript that APPEAR to do what I want, but I don't know how to put them in context of my project. Plus I know less about js than I do about php. If you know of a good source of info for that, please let me know. When I ran the above code the index.php page loaded INSIDE the iframe. My buddy says we need to do some sort of 'target=parent' so that the code in the iframe can call and pass info to the "framing" code. I KNOW this is possible but right now I just can't make this work. So tired.... Please, I'd love to hear some more ideas! Quote Link to comment Share on other sites More sharing options...
btherl Posted July 24, 2007 Share Posted July 24, 2007 Ooh, you want your iframe to trigger the parent's reload. No it can't be done with headers, but i am pretty sure it can be done with javascript. Unfortunately I'm hazy on how it works. A google for "iframe access parent" turns up sites like this: http://www.esqsoft.com/javascript_examples/iframe_talks_to_parent/ The value you want to set is probably "document.parent.location".. again I am hazy on that. "iframe refresh parent" also shows up useful stuff in google. Quote Link to comment Share on other sites More sharing options...
weemikey Posted July 24, 2007 Author Share Posted July 24, 2007 Thanks again for your reply. Yes, I need the php that's running in my iframe to pass a value to the "parent" frame and "refresh" it, whatever the syntax of that may be. Does anyone else have a javascript concept of how this works? I know very little about javascript, but that seems to be the only solution to this. Any javascript folks know where to start. I'm googling for my life, but I haven't quite found what I'm looking for. Thank ya, thank ya, thank ya! Mike Quote Link to comment Share on other sites More sharing options...
btherl Posted July 25, 2007 Share Posted July 25, 2007 Can you try this out? <script type="text/javascript"> function refresh_parent() { window.parent.location.href = window.parent.location.href; }</script> Then you can call that javascript function somewhere in your iframe. For example: <input type=button onclick='refresh_parent()'> Not sure if that will work.. and it may not be browser independent, but it's worth a try! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.