tomjung09 Posted April 24, 2009 Share Posted April 24, 2009 Is it possible to change the page of the parent of an iframe? For example if I have a main webpage: main.php and inside I have an iframe who's current page is intheframe.php, is it possible to click a button in intheframe.php and have the parent (main.php) page change? Link to comment https://forums.phpfreaks.com/topic/155571-iframes-refrencing-a-parent-of-an-iframe/ Share on other sites More sharing options...
jackpf Posted April 24, 2009 Share Posted April 24, 2009 window.parent.window.location = 'page.php'; I think... Link to comment https://forums.phpfreaks.com/topic/155571-iframes-refrencing-a-parent-of-an-iframe/#findComment-818730 Share on other sites More sharing options...
tomjung09 Posted April 25, 2009 Author Share Posted April 25, 2009 well, I tried that and it didn't work and I tried parent.window.location = 'page.php'; that didn't work either I used some javascript to get the job done but I would rather use php in the case someone doesn't have java installed. Here is the code I used: <script type="text/javascript"> <!-- parent.window.location = "http://salvagedrides.com/usa/home.php?innerframe=account" //--> </script> Now here is another one, I need to change what is inside another iframe from a different iframe, both childs of the same parent. Any ideas on that one? Link to comment https://forums.phpfreaks.com/topic/155571-iframes-refrencing-a-parent-of-an-iframe/#findComment-818778 Share on other sites More sharing options...
jackpf Posted April 25, 2009 Share Posted April 25, 2009 You can use the same logic: //put this on your parent page function chage(url) { var iframe = document.getElementById('iframe'); iframe.src = url; } //then on the iframe window.parent.window.change(http://www.google.com); Something like that anwyay. Feel free to play around with it a bit. but I would rather use php And you can't use php for something like this, as it's server side. Link to comment https://forums.phpfreaks.com/topic/155571-iframes-refrencing-a-parent-of-an-iframe/#findComment-818972 Share on other sites More sharing options...
coalgames Posted April 26, 2009 Share Posted April 26, 2009 Iframes are now a bit outdated but can still work. You could use something like this (I dont guarantee it works): <a href="somepage.htm" onclick="window.parent.window.change(somepage.htm);">Click here to go to somepage</a> Also, if you are using an iframe to change a parent, then the iframe will disappear. Here is an example I found off the web showing how to use the parent page to change the iframe: Parent window's content: <b>iframe starts here</b><br><br> <iframe src='iframe1.html'></iframe> <br><br> <b>iframe ends here</b> <script type="text/javascript"> function change_parent_url(url) { document.location=url; } </script> Iframe's content: IFRAME content<br><br> <a href="javascript:parent.change_parent_url('http://yahoo.com');"> Click here to change parent URL </a> Link to comment https://forums.phpfreaks.com/topic/155571-iframes-refrencing-a-parent-of-an-iframe/#findComment-819882 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.