SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Zealot
    Join Date
    Mar 2002
    Location
    United States
    Posts
    193
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Modifying Ordinary Hyperlinks

    I'm looking for a simple piece of code, that when it comes across a hyperlink:

    Code:
    <a href="www.blah.com">Click Here</a>
    ...it changes it to:

    Code:
    <a href="www.blah.com" target="_blank">Click Here</a>
    I run a gaming website and the news editors don't know very much HTML, and they don't want to put the target="_blank" into every hyperlink. They'd simply forget. Also, I want this code to have a closing tag of some sort, so it only changes links that are in the specified area, and nothing outside of it.

  2. #2
    SitePoint Member
    Join Date
    May 2002
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Try the following just above the </head>

    <base target="_blank">

    That's all you should need.

  3. #3
    Currently Occupied; Till Sunda Andrew-J2000's Avatar
    Join Date
    Aug 2001
    Location
    London
    Posts
    2,475
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    _blank
    _top
    _parent
    _self

    or your own (without underscore)

  4. #4
    SitePoint Zealot
    Join Date
    Mar 2002
    Location
    United States
    Posts
    193
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally posted by Cecil
    Try the following just above the </head>

    <base target="_blank">

    That's all you should need.
    But I only want this for a specific part of the page...not the whole page.

  5. #5
    SitePoint Member TonySayz's Avatar
    Join Date
    Jun 2000
    Posts
    22
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If you use the

    <base target="_blank">

    in the header, you can direct each link that you don't want to have target="_blank" with target="whatever".

    <a href="target.html"> will be targeted to "_blank"

    but

    <a href="yourtarget.html" target="yourtarget"> will be directed to "yourtarget"

    Then whenever your editors post their own articles with links they will be using the _blank target but the rest of your links will use your own target.

  6. #6
    Currently Occupied; Till Sunda Andrew-J2000's Avatar
    Join Date
    Aug 2001
    Location
    London
    Posts
    2,475
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    base has been deprecated from html 4.01 so don't use it.

  7. #7
    SitePoint Columnist Skunk's Avatar
    Join Date
    Jan 2001
    Location
    Lawrence, Kansas
    Posts
    2,066
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If you still want to use <base> I know from experience that in IE you can put it half way down a page and only links after it will be affected - then stick in another <base> tag later on to revert behaviour back to default. This is a horrible hack, I very much doubt it is supportedby the standards and gawd knows what it will do in other browsers so probably best to avoid


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
  •