Safari and opening target links in frames

Discussion in 'Web Design and Development' started by branana, Mar 30, 2006.

  1. branana macrumors member

    Joined:
    Jan 15, 2006
    #1
    I'm having a problem with my Safari. It doesn't seem to recognize frames with their names properly.

    So, say there is a frame called bob,
    and a link:

    Code:
    <a href="newpage.htm" target="bob">click</a>
    When link is clicked, newpage.htm would always open in a new safari window. This is not just for a site I made. The pages in question include various scripts, phpmyadmin etc, all of which has this target frames opening in new window issue. I am running the latest versions of OSX/Safari on 2 machines, a PPC one and a x86 one, same problem.

    The developement machine is running Apache 2, php 5.12.

    The problem happens in Webkit browsers: tested: Safari, Shiira
    The problem does NOT occur in Gecko: Firefox, Camino
    It does NOT occur in Opera either.

    Any help is appreciated, I couldn't find much information on it on Google. It's a bit WTF :(
     
  2. floyde macrumors 6502a

    floyde

    Joined:
    Apr 7, 2005
    Location:
    Monterrey, México
    #2
    Ok, here is a frameset that works in Safari. Check it out to see if there's something you missed:

    (Frameset)
    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN"
       "http://www.w3.org/TR/html4/frameset.dtd">
    <HTML>
    <HEAD>
    <TITLE>A simple frameset document</TITLE>
    </HEAD>
    <FRAMESET cols="20%, 80%">
      <FRAME src="frame.htm">
      <FRAME name="bob" src="http://www.apple.com/">
      <NOFRAMES>
          <P>This frameset document contains:
          <UL>
             <LI><A href="contents_of_frame1.html">Some neat contents</A>
             <LI><A href="contents_of_frame3.html">Some other neat contents</A>
          </UL>
      </NOFRAMES>
    </FRAMESET>
    </HTML>
    
    (Left frame)
    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head> 
    <title>Frame</title> 
    </head> 
    
    <body>
    	<div><a href="http://www.macrumors.com" target="bob">Go to macrumors!</a></div>
    </body>
    
    </html>
    
    I just found out that there's no target attribute on xhtml strict, so make sure that you are not using the strict doctype ;)
     
  3. Sean7512 macrumors 6502a

    Joined:
    Jun 8, 2005
    #3
    I had the same problem...After a bit of searching the internet, I found a EASY solution. Where you name your iframe, you need to include an "id" attribute that has the same name as your iframe. For example:

    <iframe frameborder="0" src="home.html" width="100%" height="500" id="bob" name="bob"></iframe>

    For whatever reason, Safari will not recognize the name attribute for a iframe. You need the id attribute. Make sure you use both name and id, otherwise other browsers will not work.

    EDIT: Then you would use the code the exact same as you have it (with the target="bob")
     

Share This Page