Trek15 Posted April 17, 2009 Share Posted April 17, 2009 I've got a page with only a CSS menu at the top and an iframe covering the rest of it. The items in the menu of course changes the content in the iframe, but there are also some items in it that are conditional with PHP. When someone logs in to either the blog, forum or gallery within the iframe, some of the items in the menu links to new addresses (before they linked to the forum's registration-page.) The problem is that when someone does this (log in, or log out), the menu items doesn't update with their new content, since it's outside of the iframe. Has anyone got an idea for how i can make it so that the entire page refreshes simultaneously as the function that changes the items in the menu of the parent is called? Here is a sample of the code for one of the items in the menu: <?php global $context; if ($context['user']['is_guest']) echo '<li><a href="javascript:loadintoIframe(\'frame\', \'.../forum/index.php?action=register\')">Chat</a></li>;'; else echo '<li><a href="javascript:loadintoIframe(\'frame\', \'.../chat.php\')">Chat</a></li>'; ?> Quote Link to comment Share on other sites More sharing options...
.josh Posted April 17, 2009 Share Posted April 17, 2009 inside your iframe code, you can use window.parent to target the parent window (using js). So if you want to "refresh" the page, you can do for instance window.parent.href='urlhere' or window.parent.reload() etc.. You can target elements etc.. doing window.parent.getElementById('idhere') etc... Quote Link to comment Share on other sites More sharing options...
Trek15 Posted April 17, 2009 Author Share Posted April 17, 2009 Thank you. But how do i make that code aware of when someone logs in/out? I don't want the parent to refresh at all times. Quote Link to comment Share on other sites More sharing options...
.josh Posted April 17, 2009 Share Posted April 17, 2009 well if you have a login system in place, then you already have code that does stuff based on user logging in/out. you just put it on your login/logout landing page(s). So when they load up, the js code gets executed. Quote Link to comment Share on other sites More sharing options...
Trek15 Posted April 17, 2009 Author Share Posted April 17, 2009 Well then i would have to edit the actual pages within the iframe, and not the iframe itself. How would a complete JS code look like in this case, that i could paste into the landing pages? Quote Link to comment Share on other sites More sharing options...
.josh Posted April 17, 2009 Share Posted April 17, 2009 those examples are the complete code. Slap script tags around one of them and paste to your page. 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.