1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

CSS rule for _blank

Discussion in 'Web Design & Development' started by Ziggy1, Jan 23, 2011.

Thread Status:
Not open for further replies.
Advertisement
  1. Ziggy1

    Ziggy1 Thread Starter

    Joined:
    Jun 17, 2002
    Messages:
    2,551
    I have a bunch of links in a verticle (Spry) menu and I thought it would be useful if i could make a "Rule" to apply target=_blank to all links?

    I thought maybe it would go in the a:link rule of my css page, but not sure how to put it together.


    **working with DW CS5

    thanks
     
  2. lordsmurf

    lordsmurf

    Joined:
    Apr 23, 2009
    Messages:
    1,156
    No. That's not CSS. That's HTML.
     
  3. sepala

    sepala

    Joined:
    May 20, 2010
    Messages:
    4,038
    Agree with lordmurf. That is HTML.
     
  4. dvk01

    dvk01 Moderator Malware Specialist

    Joined:
    Dec 14, 2002
    Messages:
    56,236
    First Name:
    Derek
  5. ehymel

    ehymel

    Joined:
    Aug 12, 2007
    Messages:
    696
    Can also be done in jquery, which helps ensure cross-browser compatibility. Also requires minimal changes to your existing pages.

    Code:
    $('a').attr('target','_blank');
    This can additionally offer targeting of a specific class of links. For example, if you define a link (<a href>) as having a class like 'newWindow', you can apply the above rule to only that class of links like so:
    Code:
    $('a.newWindow').attr('target','_blank');
     
  6. DrP

    DrP

    Joined:
    Jul 23, 2005
    Messages:
    739
  7. colinsp

    colinsp

    Joined:
    Sep 5, 2007
    Messages:
    2,270
    First Name:
    Colin
    But only in CSS3 not in CSS2.
     
  8. Ziggy1

    Ziggy1 Thread Starter

    Joined:
    Jun 17, 2002
    Messages:
    2,551
    Thanks, DVK01 & ehymel, I will try it and let you know
     
  9. lordsmurf

    lordsmurf

    Joined:
    Apr 23, 2009
    Messages:
    1,156
    Meaning it doesn't work in IE6, IE7 or IE8. (n)
     
  10. ehymel

    ehymel

    Joined:
    Aug 12, 2007
    Messages:
    696
    Thus the attraction to JQuery for me...
     
  11. Sponsor

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/976556

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice