SitePoint Sponsor

User Tag List

Results 1 to 21 of 21
  1. #1
    SitePoint Zealot
    Join Date
    Sep 2000
    Location
    Birmingham, AL
    Posts
    120
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    iframe target question

    I'm having problems with the target in an iframe within my tree menu navigation.

    I would like to open the URLs that are inside the iframe in the same window of the browser and not in a new window. However, I can't get either to work. The links just keep opening in the iframe.

    What am I doing wrong?

    Code:
     <IFRAME SRC="filename.asp" target="_top" frameborder="0" height="100%" scrolling="yes"></IFRAME>

  2. #2
    Formerly known as RockNRollPig Shpigford's Avatar
    Join Date
    Dec 2002
    Location
    Denver, CO
    Posts
    2,877
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    have you tried target="_self" or "_parent"?

  3. #3
    SitePoint Zealot
    Join Date
    Sep 2000
    Location
    Birmingham, AL
    Posts
    120
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yeah - still opens in iframe.

    These html files that are in the iframe where created in Excel are and being included in the html. So there's now way in Excel to edit the link and to tell it a target. If you could, I dont think I would have this problem.
    Joseph Schell
    AMICO-Online

  4. #4
    gingham dress, army boots... silver trophy redux's Avatar
    Join Date
    Apr 2002
    Location
    Salford / Manchester / UK
    Posts
    4,838
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    aeh...the "target" attribute goes in your links (in the document that is loaded into the iframe), not in the iframe definition itself...can you not do a find&replace of those excel-generate documents, to add a target="_top" or whatever to it ? find <a replace with <a target="_top" ...
    re·dux (adj.): brought back; returned. used postpositively
    [latin : re-, re- + dux, leader; see duke.]
    WaSP Accessibility Task Force Member
    splintered.co.uk | photographia.co.uk | redux.deviantart.com

  5. #5
    Formerly known as RockNRollPig Shpigford's Avatar
    Join Date
    Dec 2002
    Location
    Denver, CO
    Posts
    2,877
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    haha...duh....i just noticed that as well that he code up there was the iframe code and not the links code...

  6. #6
    SitePoint Zealot
    Join Date
    Sep 2000
    Location
    Birmingham, AL
    Posts
    120
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Technically I could, but these excel files generated into html files will constantly be updated by others throughout each day, so that really wouldn't work.
    Joseph Schell
    AMICO-Online

  7. #7
    SitePoint Wizard davidjmedlock's Avatar
    Join Date
    Dec 2002
    Location
    Nashville, TN USA
    Posts
    1,688
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Edit:

    messed up

  8. #8
    SitePoint Wizard davidjmedlock's Avatar
    Join Date
    Dec 2002
    Location
    Nashville, TN USA
    Posts
    1,688
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    OKay this is a huge shot in the dark, so I won't even claim that it will work. If it does work, it may not in all browsers:

    Code:
    function setTargets() {
      for (i = 0; i < document.links.length; i++) {
        document.links[i].target = "_top";
      }
    }
    Put that in your <body onLoad> event.

  9. #9
    SitePoint Zealot
    Join Date
    Sep 2000
    Location
    Birmingham, AL
    Posts
    120
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'm assuming I put this in right? If so it didn't work.

    Code:
     <script language="JavaScript">
    function setTargets() {
    for (i = 0; i < document.a.length; i++) {
    document.a[i].target = "_top";
    }
    }</script>

  10. #10
    gingham dress, army boots... silver trophy redux's Avatar
    Join Date
    Apr 2002
    Location
    Salford / Manchester / UK
    Posts
    4,838
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    (i think without any server-side scripting, this will have to rely on some javascript solution...unless you're willing to ditch the iframe altogether - so i'm moving this to the javascript section)
    re·dux (adj.): brought back; returned. used postpositively
    [latin : re-, re- + dux, leader; see duke.]
    WaSP Accessibility Task Force Member
    splintered.co.uk | photographia.co.uk | redux.deviantart.com

  11. #11
    SitePoint Wizard davidjmedlock's Avatar
    Join Date
    Dec 2002
    Location
    Nashville, TN USA
    Posts
    1,688
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by uwajes
    I'm assuming I put this in right? If so it didn't work.

    Code:
     <script language="JavaScript">
    function setTargets() {
    for (i = 0; i < document.a.length; i++) {
    document.a[i].target = "_top";
    }
    }</script>
    Code:
      function setTargets() {
        for (i = 0; i < document.links.length; i++) {
          document.links[i].target = "_top";
        }
      }
    I screwed up the first post and didn't put the right code in there. I corrected it above and in the previous post. I didn't test it, though, so i may not work.

  12. #12
    SitePoint Zealot
    Join Date
    Sep 2000
    Location
    Birmingham, AL
    Posts
    120
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by davidjmedlock
    I screwed up the first post and didn't put the right code in there. I corrected it above and in the previous post. I didn't test it, though, so i may not work.
    Still a no go.
    Joseph Schell
    AMICO-Online

  13. #13
    SitePoint Zealot
    Join Date
    Sep 2000
    Location
    Birmingham, AL
    Posts
    120
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Maybe the iframe isn't the way to go. Here's what I need to do...

    I have a tree menu that works pretty good, but the problem is that it won't save your location in the tree when you go to a page and then come back to the nav.

    Is there a better way to do this?


  14. #14
    SitePoint Wizard davidjmedlock's Avatar
    Join Date
    Dec 2002
    Location
    Nashville, TN USA
    Posts
    1,688
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Use target="_parent" in the javascript, that should work just fine.

  15. #15
    SitePoint Zealot
    Join Date
    Sep 2000
    Location
    Birmingham, AL
    Posts
    120
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Still didn't work...

  16. #16
    SitePoint Zealot simplyunique's Avatar
    Join Date
    Jun 2003
    Location
    Montreal
    Posts
    166
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    your iframe solution is simple.

    First let me see if i have your problem right..

    Youve got an iframe on your page with links in it, you want these links to target top and kill the current page. Then do it. That's all there is to it. If it's not working, let me see your files. I'll fix it.

    Here visit this url, http://raffiaonline.com/high/about-us/security.htm the internet secure image is in the iframe, clicking it opens it in a new window. I've tested parent and that works too.
    Fonkuscious say: Sink a foot in into my code and stub your toe

  17. #17
    SitePoint Zealot
    Join Date
    Sep 2000
    Location
    Birmingham, AL
    Posts
    120
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I've actually given up on using iframes in my tree menu navigation. I'm just taking a different and better approach to it. Thanks for the help.

  18. #18
    SitePoint Member
    Join Date
    Jul 2004
    Location
    PA, USA
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Was this ever solved? I was thinking of loading a basic page into the IFRAME (setting BASE TARGET) and then calling an iframe inside that that is the same size. It might be messy but it may work without having to modify the final loaded dynamic document.

    Anybody have an idea if this would work?

  19. #19
    SitePoint Member
    Join Date
    Aug 2004
    Location
    USA
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Same problem..

    Can you please let me know the alternate solution?
    Because I'm also having the same problem of iFrame links getting opened in the iFrame itself, I tried hard to get solution over the internet but couldn't.
    Any help is greatly appreciated.
    Thanks in advance

  20. #20
    SitePoint Member
    Join Date
    Apr 2005
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Fix?

    I use an <IFRAME> tag on my site for IE users only. I guess what I use it for is irrelevant, but I have a link (<A HREF="" ></A>) within the IFRAME and I wanted to have that link load in the full browser window. I first had a problem with the <A HREF="" TARGET="_top"> tag as it was loading as if you used "TARGET=_new". It seems that using "_parent" fixed the issue. Has anyone come across a JAVA script version of <IFRAME> that works in all browsers? The key is not to have the main page reload when I'm targeting the frame area, but when clicking in any link within that area, to load in the main page.

  21. #21
    SitePoint Zealot simplyunique's Avatar
    Join Date
    Jun 2003
    Location
    Montreal
    Posts
    166
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    In an external js file..

    Code:
    contPage = (location.search.substring(1))? location.search.substring(1) : 'http://whatever.com/default_iframe_contentfilename.htm';
    contPage = unescape(contPage);
    document.write('<iframe src="'+contPage+'" name="content" width="450" height="200" frameborder="0" scrolling="auto">');
    document.write('</iframe>');
    Wheverever you want it.
    Code:
     
    <script type="text/javascript"  language="JavaScript" src="../css_js/iframe_section1.js"></script>
    If you have different sections with different default content this is a handy script. Target="content" .
    Fonkuscious say: Sink a foot in into my code and stub your toe


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
  •