SitePoint Sponsor

User Tag List

Results 1 to 8 of 8
  1. #1
    SitePoint Member
    Join Date
    Aug 2003
    Location
    Frisco
    Posts
    15
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    How do you open a new window?

    Hi,
    When someone clicks on a link to another website from my website, how can I have that other website open in a new window instead of replacing my website window?

    I just want the person on my website to not have to use the back button to get back to my site after viewing the link.

    Or, is there yet another way?

    Thanks!
    fewcoin

  2. #2
    SitePoint Enthusiast GCT13's Avatar
    Join Date
    Jul 2003
    Location
    Champaign, IL
    Posts
    37
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Add target="_blank" to your <a> tags. Like this:

    <a href="http://othersite.com" target="_blank">othersite.com</a>
    Last edited by GCT13; Nov 21, 2003 at 10:05.
    ...

  3. #3
    SitePoint Wizard
    Join Date
    Mar 2002
    Location
    Bristol, UK
    Posts
    2,240
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    target="_blank" works, but is not valid HTML.

    The way I do it is uses a bit of java script:
    Code:
    <a href="(URL)" onclick="window.open(this.href);return false;">Click Here</a>
    This will open a new window in a standards-compliant way. And the good thing about it is, if the user has JavaScript turned off, then the page opens in the same window [img]images/smilies/smile.gif[/img]

    -Sam
    Sam Hastings

  4. #4
    SitePoint Member
    Join Date
    Aug 2003
    Location
    Frisco
    Posts
    15
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for the replies, I'll try them both out today. They're both short and sweet, to the point. I'll edit my website today to incooperate the new coding.

    I looked in my html books earlier but they all seem to give unclear answers. As usual, these forums are great.

    fewcoin

  5. #5
    SitePoint Wizard
    Join Date
    Mar 2002
    Location
    Bristol, UK
    Posts
    2,240
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Sorry, just to clarify:

    target="_blank" is no longer valid HTML. If you're using HTML 4, it's fine, but according to today's standards (XHTML standards), it's not supported

    -Sam
    Sam Hastings

  6. #6
    ☆★☆★ silver trophy vgarcia's Avatar
    Join Date
    Jan 2002
    Location
    in transition
    Posts
    21,235
    Mentioned
    1 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by Devilware.net
    Sorry, just to clarify:

    target="_blank" is no longer valid HTML. If you're using HTML 4, it's fine, but according to today's standards (XHTML standards), it's not supported

    -Sam
    To clarify even further:

    The target attribute is fine to use under XHTML 1.0 Transitional. It's under XHTML 1.0 Strict and XHTML 1.1 where it's not part of the spec anymore .

  7. #7
    SitePoint Addict
    Join Date
    Sep 2003
    Location
    Europe
    Posts
    222
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by fewcoin
    I just want the person on my website to not have to use the back button to get back to my site after viewing the link.
    But that's exactly what most people want! I (and many people with me) hate it to have their screen cluttered with multiple browser windows!

  8. #8
    SitePoint Wizard silver trophy TheOriginalH's Avatar
    Join Date
    Aug 2000
    Location
    Thailand
    Posts
    4,810
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by yngwin
    But that's exactly what most people want! I (and many people with me) hate it to have their screen cluttered with multiple browser windows!
    Breaking #1 & #2 of the top ten web design boobs ala M. Nielson
    ~The Artist Latterly Known as Crazy Hamster~
    922ee590a26bd62eb9b33cf2877a00df
    Currently delving into Django, GIT & CentOS


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
  •