Jump to content

iframes refrencing a parent of an iframe


tomjung09

Recommended Posts

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?

 

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.

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>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.