SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    Barefoot on the Moon! silver trophy Force Flow's Avatar
    Join Date
    Jul 2003
    Location
    Northeastern USA
    Posts
    4,617
    Mentioned
    56 Post(s)
    Tagged
    1 Thread(s)

    links in an IFRAME src page

    If you're using an IFRAME on a page that loads a seperate src page, any links you click on in the IFRAME will load in the IFRAME. How can you get it so that any links you click on will open in the current browser window?

    Here's the page I'm working with:
    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <title>Untitled Document</title>
    <script language="JavaScript" type="text/javascript">
    <!--
    function loadNewFrame(newAddress){
    
    document.getElementById('myframe').src = newAddress;
    
    }
    //-->
    </script>
    </head>
    
    <body>
    <p><a href="#" onclick="loadNewFrame('http://google.com');">page1</a></p>
    <p><a href="#" onclick="loadNewFrame('http://sitepoint.com');">page2</a></p>
    <p>
      <iframe name="myframe" id="myframe" width="90%" height="300px" frameborder="0px" src="http://yahoo.com/"></iframe>
    </p>
    <p>&nbsp;</p>
    </body>
    </html>

  2. #2
    SitePoint Wizard chris_fuel's Avatar
    Join Date
    May 2006
    Location
    Ventura, CA
    Posts
    2,750
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi,

    If you have control over the code inside the iframe, then you can use target="_top" in your links. This will load the document in the topmost frame, which is either the parent frame of the document, or the document itself.

  3. #3
    Barefoot on the Moon! silver trophy Force Flow's Avatar
    Join Date
    Jul 2003
    Location
    Northeastern USA
    Posts
    4,617
    Mentioned
    56 Post(s)
    Tagged
    1 Thread(s)
    Ok, that worked for IE6 and Firefox 1.5, but not Opera 9.

    Is there something along those lines that would work with opera?

  4. #4
    SitePoint Wizard chris_fuel's Avatar
    Join Date
    May 2006
    Location
    Ventura, CA
    Posts
    2,750
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    To be honest I'm not sure why that doesn't work in opera, as it's a standard attribute

  5. #5
    Barefoot on the Moon! silver trophy Force Flow's Avatar
    Join Date
    Jul 2003
    Location
    Northeastern USA
    Posts
    4,617
    Mentioned
    56 Post(s)
    Tagged
    1 Thread(s)
    ok, that's odd.

    Just for the heck of it, I tried it in safari and it worked. Usually safari is the odd-ball one.

  6. #6
    SitePoint Wizard chris_fuel's Avatar
    Join Date
    May 2006
    Location
    Ventura, CA
    Posts
    2,750
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Like I said, it's a W3 standard, I call bug .

  7. #7
    Barefoot on the Moon! silver trophy Force Flow's Avatar
    Join Date
    Jul 2003
    Location
    Northeastern USA
    Posts
    4,617
    Mentioned
    56 Post(s)
    Tagged
    1 Thread(s)
    ah ah...found the problem.

    The page that was being linked to isn't really coded well. I started from scratch and threw up a a temporary test page and it worked fine like in the other browsers.


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
  •