Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 12 of 12

Thread: External Link

  1. #1
    New Coder
    Join Date
    Jul 2008
    Posts
    61
    Thanks
    10
    Thanked 0 Times in 0 Posts

    Question External Link

    How do i make it so the link opens in a new page?
    Last edited by nathan130; 10-24-2008 at 03:16 AM.

  • #2
    Senior Coder rangana's Avatar
    Join Date
    Feb 2008
    Location
    Cebu City, Philippines
    Posts
    1,752
    Thanks
    65
    Thanked 372 Times in 365 Posts
    Code:
    <a href="http://www.google.com" target="_blank">Open Google in new window</a>
    For further reading:
    http://www.w3schools.com/TAGS/tag_a.asp
    http://www.htmlcodetutorial.com/linking/_A_TARGET.html
    http://www.trilithium.com/johan/2005/03/target-blank/

    ...but you should also note that having target attribute will fail validation on strict doctype.
    Learn how to javascript at 02geek

    The more you learn, the more you'll realize there's much more to learn
    Ray.ph

  • Users who have thanked rangana for this post:

    nathan130 (10-24-2008)

  • #3
    Senior Coder
    Join Date
    Feb 2003
    Posts
    1,665
    Thanks
    0
    Thanked 27 Times in 25 Posts

  • #4
    Senior Coder
    Join Date
    Jul 2005
    Location
    UK
    Posts
    1,051
    Thanks
    6
    Thanked 13 Times in 13 Posts
    Really interesting idea there Bill - but the links don't work for me once I've toggled them to open in a new window. Looking at it, I can't see how you are getting them to open in a new window - JavaScript? Perhaps that's the root of the problem?

  • #5
    Senior Coder gnomeontherun's Avatar
    Join Date
    Sep 2007
    Location
    Houston
    Posts
    2,846
    Thanks
    10
    Thanked 238 Times in 229 Posts
    I think the important part of that post is to show it is a good idea to have a little 'new window' icon near external links. This way they know they are external. Then they can choose to open them in a new window or tab themselves. That way the browsing experience is more in control of the visitor, which gives them a nice warm feeling inside.
    jeremy - gnomeontherun
    Educated questions often get educated answers, and simple questions often get simple answers.

  • #6
    Senior Coder
    Join Date
    Feb 2003
    Posts
    1,665
    Thanks
    0
    Thanked 27 Times in 25 Posts
    Quote Originally Posted by Pennimus View Post
    Really interesting idea there Bill - but the links don't work for me once I've toggled them to open in a new window. Looking at it, I can't see how you are getting them to open in a new window - JavaScript? Perhaps that's the root of the problem?
    Now fixed.
    I must have absent-mindedly fiddled with the code and left it unfinished/broken.

    I've also ditched the non-jQuery options (simpler for maintenance, as I use jQuery as my primary framework).

    HTH



    …all fwiw, of course.

  • #7
    Master Coder
    Join Date
    Dec 2007
    Posts
    6,682
    Thanks
    436
    Thanked 890 Times in 879 Posts
    Quote Originally Posted by nathan130 View Post
    How do i make it so the link opens in a new page?
    for html can use target as rangana said or in xhtml can use javascript:

    Code:
    <a href="your url here" onclick="window.open('your url here'); return false;">....</a>
    url in both places, must be in href for the case when javascript is disabled.

    best regards

  • #8
    Senior Coder
    Join Date
    Feb 2003
    Posts
    1,665
    Thanks
    0
    Thanked 27 Times in 25 Posts
    Quote Originally Posted by oesxyl View Post
    for html can use target as rangana said or in xhtml can use javascript:
    Fwiw, it's not an HTML compared to XHTML issue. It's a Transitional compared to Strict issue. The target attribute is not valid in either HTML 4.01 Strict or XHTML 1.0 Strict.

    Code:
    <a href="your url here" onclick="window.open('your url here'); return false;">....</a>

    To save a little time, you don't need to repeat the href value in the window.open() method. Simply refer back to the href value in the js.

    e.g.
    Code:
    <a href="your url here" onclick="window.open(this.href); return false;">....</a>
    Last edited by Bill Posters; 10-27-2008 at 06:14 PM.

  • #9
    The Apostate Apostropartheid's Avatar
    Join Date
    Oct 2007
    Posts
    3,215
    Thanks
    16
    Thanked 265 Times in 263 Posts
    I feel obligated to point out that opening links in new windows is both annoying in the tabbed age and isn't good for accessibility.

  • #10
    Senior Coder gnomeontherun's Avatar
    Join Date
    Sep 2007
    Location
    Houston
    Posts
    2,846
    Thanks
    10
    Thanked 238 Times in 229 Posts
    Quote Originally Posted by CyanLight View Post
    I feel obligated to point out that opening links in new windows is both annoying in the tabbed age and isn't good for accessibility.
    Thank you! Exactly what I was trying to say!
    jeremy - gnomeontherun
    Educated questions often get educated answers, and simple questions often get simple answers.

  • #11
    Rockstar Coder
    Join Date
    Jun 2002
    Location
    USA
    Posts
    9,074
    Thanks
    1
    Thanked 328 Times in 324 Posts
    Quote Originally Posted by CyanLight View Post
    I feel obligated to point out that opening links in new windows is both annoying in the tabbed age and isn't good for accessibility.
    I agree, you should only open new windows when absolutely necessary.
    OracleGuy

  • #12
    Master Coder
    Join Date
    Dec 2007
    Posts
    6,682
    Thanks
    436
    Thanked 890 Times in 879 Posts
    Quote Originally Posted by nathan130 View Post
    How do i make it so the link opens in a new page?
    Quote Originally Posted by CyanLight View Post
    I feel obligated to point out that opening links in new windows is both annoying in the tabbed age and isn't good for accessibility.
    Quote Originally Posted by jeremywilken View Post
    Thank you! Exactly what I was trying to say!
    Quote Originally Posted by oracleguy View Post
    I agree, you should only open new windows when absolutely necessary.
    I'm not agree, if you don't abuse it is ok. Anyway this was op request.

    best regards


  •  

    Posting Permissions

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