SitePoint Sponsor

User Tag List

Results 1 to 8 of 8
  1. #1
    SitePoint Guru
    Join Date
    Dec 2005
    Posts
    964
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Setting parent url from iFrame!?

    Is it possible to set the parent url from within an iframe...

    Let's say that I have an url: http://www.mypage.com/index.php.
    And within this page I have an iframe which source is: http://www.mypage.com/myiframe.php. In this page I have a link (<a href="http://www.mypage.com/index.php?page=newpage">)

    Now I want to change the parent link when hitting this link... But don't know how... Please help!

  2. #2
    From Italy with love silver trophybronze trophy
    guido2004's Avatar
    Join Date
    Sep 2004
    Posts
    9,398
    Mentioned
    147 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by jmansa View Post
    Now I want to change the parent link when hitting this link
    What do you mean?

  3. #3
    SitePoint Enthusiast
    Join Date
    Mar 2009
    Posts
    39
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I think what you may want is

    <a href="link-in-frame-page" target="_top">text</a>

    The _Top over-rides the iframe you're in and changes the overall page.
    http://webdevsforum.com/ - New Web Developers Forum
    http://classifiedphpscript.com/ - PHP Classifieds $10

  4. #4
    SitePoint Zealot iScrawl's Avatar
    Join Date
    Mar 2009
    Posts
    112
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Try using the target attribute of the A Href tag:
    Code:
    <a href=yoursite target=_top>click here</a>
    Hanan Moiseyev
    Online games and Videos - http://www.playwithroger.com
    Share your art - http://www.iscrawl.com

  5. #5
    SitePoint Guru
    Join Date
    Dec 2005
    Posts
    964
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I found this, but can this be done without javascript?
    Code:
    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>

  6. #6
    SitePoint Zealot iScrawl's Avatar
    Join Date
    Mar 2009
    Posts
    112
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Look at answer 3 and 4....
    Hanan Moiseyev
    Online games and Videos - http://www.playwithroger.com
    Share your art - http://www.iscrawl.com

  7. #7
    From Italy with love silver trophybronze trophy
    guido2004's Avatar
    Join Date
    Sep 2004
    Posts
    9,398
    Mentioned
    147 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by iScrawl View Post
    Look at answer 3 and 4....
    And if that isn't what you want, answer the question in answer 2

  8. #8
    SitePoint Guru
    Join Date
    Dec 2005
    Posts
    964
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks... The _top did the job...


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •