html request

Discussion in 'Web Design & Coding' started by Perris Calderon, Nov 28, 2008.

  1. Perris Calderon

    Perris Calderon Moderator Staff Member Political User

    Messages:
    12,333
    Location:
    new york
    hey, could someone tell me how they code this
    on ths site?

    http://www.eschatonblog.com/

    there are some other wordpress blogs that would like the feature, I'd love to tell them how to do it
     
  2. LordOfLA

    LordOfLA Godlike!

    Messages:
    7,027
    Location:
    Maidenhead, Berkshire, UK
    target="_blank"
     
  3. Perris Calderon

    Perris Calderon Moderator Staff Member Political User

    Messages:
    12,333
    Location:
    new york
    thanx lord, could you show me the way the entire thing would look?

    use code /code

    thanx, preciate it
     
  4. LordOfLA

    LordOfLA Godlike!

    Messages:
    7,027
    Location:
    Maidenhead, Berkshire, UK
    Code:
    <a href="http://www.osnn.net" target="_blank">OSNN</a>
    Naturally there will be code needed to check if an option is set as to whether it should put the target attribute there.

    In php you could do something like

    Code:
    <?php
        if ($new_window == true)
        {
            echo "<a href=\"http://www.osnn.net\" target=\"_blank\">OSNN</a>";
         }
         else
         {
            echo "<a href=\"http://www.osnn.net\">OSNN</a>";
         }
    ?>
    
    May need to replace \" with ' been a few months since I last did PHP coding.

    May also just set a variable called $target_attribute to contain target="_blank" if $new_window is set and just echo it in the tag - if its not set nothing shows, if it is you get the target attribute set.
     
  5. Perris Calderon

    Perris Calderon Moderator Staff Member Political User

    Messages:
    12,333
    Location:
    new york
    thanx, will pass it on, I doubt they know enough to make it work but they'll have something to research
     
  6. Electronic Punk

    Electronic Punk Administrator Staff Member Political User Folding Team

    Messages:
    18,590
    Location:
    Copenhagen, Denmark
    I used to use these on the frontpage, but speedy said something I am always reminded of when looking over these things - if folks wanted to open pages in a new window they would do it themselves :)
     
  7. Henyman

    Henyman Secret Goat Fetish Political User

    exactly that.
     
  8. jukkish

    jukkish OSNN One Post Wonder

    Messages:
    2
    I think good rule is to open external links to new windows and internal links to same window.


    I'm not sure if check box is done with php, I would suspect javascript and possibly AJAX, because it doesn't seem to reload page after checking or unchecking the box.
     
  9. Geffy

    Geffy Moderator Folding Team

    Messages:
    7,805
    Location:
    United Kingdom
    I think in a world of tabbed browsers and being able to middle click "open link in new tab" no link should ever open in a new window. Some popups have their place but thats rare.

    Also if your using the target attribute remember to set your HTML Doctype to HTML4 and not XHTML as target isn't valid in XHTML. I can't remember whats happened to it in HTML5.
     
    Perris Calderon likes this.
  10. Perris Calderon

    Perris Calderon Moderator Staff Member Political User

    Messages:
    12,333
    Location:
    new york
    we all have our preferances geffy, that's why this feature is an opt in rather then default

    I personally would much rather a new window then a new tab when I'm on a page that I don't want to navigate away from

    while I do use tab browsing at times, to me it is redundant, if you open a new window there is a tab for that window in your task bar and I just don't get the whole tabbed browser fetish

    amyway, the feature on this site is opt in and that satisfies everyone, those like yourself who believe you should not "break the back button" and those like me who think you should not be mavigating from a page you haven't finnished

    by the way, what is the code to add to links if you want a tab to open in the backround instead of the forground
     
    Last edited: Dec 4, 2008
  11. LordOfLA

    LordOfLA Godlike!

    Messages:
    7,027
    Location:
    Maidenhead, Berkshire, UK
    well for people like me tabbed browsing means my task bar buttons dont get shrunk down to application icons with all the windows I would have open.

    Browser configuration will change link behaviour to new windows or tabs.
     
  12. Perris Calderon

    Perris Calderon Moderator Staff Member Political User

    Messages:
    12,333
    Location:
    new york
    true enough but then you take up real estate below the title bar and I canot stand that

    6 or half a dozen, it's preference and that's all, that's why it's such a good idea to let the user decide

    I like the way my browser opens links on most sites now and don't want a different configuration, I don't want every link opening in a new window, links off site I like to open in a new window, windows on site I want to open in the same window

    just the way this board functions I might add

    that's the beauty of the feature, the user decides how they want the page to address links not the person coding the site...brilliant concept
     
    Last edited: Dec 4, 2008
  13. osnnraptor

    osnnraptor OSNN One Post Wonder

    Messages:
    6
    this particular site uses javascript (php is not a good option since after you check the checkbox you need to reload the page)
    Code:
    <script type="text/javascript">
    <!--
    // thanks to randomwalks.com for this code
    
    function targetLinks(boNew)
    {
    
    if (boNew) where = "_blank";
    else where = "_self";
    for (var i=0; i <=(document.links.length-1); i++)
    {
    
    if (document.links[i].href.indexOf("javascript") == -1 ){
    document.links[i].target = where;
    }
    }
    
    
    } 
    
    
    //-->
    </script>
    
     
    Last edited by a moderator: Dec 11, 2008