how do i let links open in a new window using css?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • nico-t
    emperor of my world
    • Aug 2004
    • 29903

    #1

    how do i let links open in a new window using css?

    I wanna use a class in css to define that the links between that class's tags on the actual page open up in a new window.

    Lets say i wanna call this class 'blanktarget', whats the code i gotta put in the style sheet file? U know something like this:
    Code:
    .blanktarget a {
        href:blank;
    }
    (^^^^ improvised code just for an example)

    so that the links between these tags:
    <div class="blanktarget"></div>
    open up in a new window.
  • kenny
    Confirmed User
    • Mar 2002
    • 7245

    #2
    Why don't you just use TARGET="_blank" in your links like normal?
    7

    Comment

    • nico-t
      emperor of my world
      • Aug 2004
      • 29903

      #3
      Originally posted by kenny
      Why don't you just use TARGET="_blank" in your links like normal?
      its a hardlink trade list in my blog, but u add the links quickly thru an admin panel..i dont wanna get into the source too everytime i add a link.

      Comment

      • Rorschach
        So Fucking Banned
        • Aug 2002
        • 5579

        #4
        some people really like to make things more difficult for themselves than they have to be...

        Comment

        • nico-t
          emperor of my world
          • Aug 2004
          • 29903

          #5
          Originally posted by Rorschach
          some people really like to make things more difficult for themselves than they have to be...
          like you ?

          Comment

          • kenny
            Confirmed User
            • Mar 2002
            • 7245

            #6
            Originally posted by nico-t
            its a hardlink trade list in my blog, but u add the links quickly thru an admin panel..i dont wanna get into the source too everytime i add a link.
            Can't you edit the program?
            7

            Comment

            • nico-t
              emperor of my world
              • Aug 2004
              • 29903

              #7
              no its a bit more complicated then this. If i could do it more simple id already done it.

              Comment

              • xlogger
                Confirmed User
                • Jul 2004
                • 9507

                #8
                Just add this below </head> ..

                <base target="_blank">
                ..and all the links will open in new window.

                ----------
                XLOGGER [REFLECTED] [OH]

                Comment

                • kenny
                  Confirmed User
                  • Mar 2002
                  • 7245

                  #9
                  Originally posted by xlogger
                  Just add this below </head> ..



                  ..and all the links will open in new window.
                  There is some HTML that I never knew existed !

                  You should tell that to whoever wrote this:

                  http://www.developertutorials.com/tu...311/page1.html

                  7

                  Comment

                  • swedguy
                    Confirmed User
                    • Jan 2002
                    • 7981

                    #10
                    It's not possible.

                    Comment

                    • nico-t
                      emperor of my world
                      • Aug 2004
                      • 29903

                      #11
                      Originally posted by xlogger
                      Just add this below </head> ..



                      ..and all the links will open in new window.
                      thanks, but i want just several "blocks" of links to open in a new window, not the whole page....
                      Its a wordpress blog, with several php files/templates etc thrown together when u visit the site, thats why the way i want it is, as far as i know, the only option really...

                      Comment

                      • nico-t
                        emperor of my world
                        • Aug 2004
                        • 29903

                        #12
                        Originally posted by swedguy
                        It's not possible.
                        christ.... u know this 100% sure?

                        Comment

                        • kenny
                          Confirmed User
                          • Mar 2002
                          • 7245

                          #13
                          Originally posted by swedguy
                          It's not possible.
                          doesn't this code do it? Or am I reading this wrong?

                          http://www.developertutorials.com/tu...311/page1.html
                          7

                          Comment

                          • kenny
                            Confirmed User
                            • Mar 2002
                            • 7245

                            #14
                            It's javascript.. but thats ok isn't it?
                            7

                            Comment

                            • Robertf
                              Confirmed User
                              • Feb 2004
                              • 392

                              #15
                              You can't do that in CSS ....

                              As suggested before .. or you let all open i na new window or you will have to add target=.. to the links you wanne open in a new window.
                              ....

                              Comment

                              • nico-t
                                emperor of my world
                                • Aug 2004
                                • 29903

                                #16
                                ok so no css...
                                Originally posted by kenny
                                doesn't this code do it? Or am I reading this wrong?

                                http://www.developertutorials.com/tu...311/page1.html
                                ^^ this might actually work... the internal links, like the category links all open in the same window when i put my domain name in that piece of code.. so im gonna give this one a try! Thanks for the link

                                Comment

                                • swedguy
                                  Confirmed User
                                  • Jan 2002
                                  • 7981

                                  #17
                                  Originally posted by kenny
                                  doesn't this code do it? Or am I reading this wrong?

                                  http://www.developertutorials.com/tu...311/page1.html
                                  Javascript is not the same thign as CSS.

                                  Comment

                                  • kenny
                                    Confirmed User
                                    • Mar 2002
                                    • 7245

                                    #18
                                    Originally posted by swedguy
                                    Javascript is not the same thign as CSS.

                                    I was more or less looking for any kind of a solution
                                    7

                                    Comment

                                    • nico-t
                                      emperor of my world
                                      • Aug 2004
                                      • 29903

                                      #19
                                      since css doesnt have this sort of code its a good substite, i just tested this javascript code, and it works perfectly! my blog is now exactly the way i want, thanks

                                      Comment

                                      • kenny
                                        Confirmed User
                                        • Mar 2002
                                        • 7245

                                        #20
                                        Originally posted by nico-t
                                        ok so no css...

                                        ^^ this might actually work... the internal links, like the category links all open in the same window when i put my domain name in that piece of code.. so im gonna give this one a try! Thanks for the link

                                        I hope it works out for you

                                        Of course your surfers without javascript aren't going to like it
                                        7

                                        Comment

                                        • nico-t
                                          emperor of my world
                                          • Aug 2004
                                          • 29903

                                          #21
                                          Originally posted by kenny
                                          I hope it works out for you

                                          Of course your surfers without javascript aren't going to like it
                                          yeah ok, but who aint got javascript these days? i thought all the browsers got javascript, only not when u disable it yourself manually.... so i think this solution is fine

                                          Comment

                                          • misterwalrus
                                            Confirmed User
                                            • Jan 2001
                                            • 270

                                            #22
                                            Originally posted by nico-t
                                            thanks, but i want just several "blocks" of links to open in a new window, not the whole page....
                                            Its a wordpress blog, with several php files/templates etc thrown together when u visit the site, thats why the way i want it is, as far as i know, the only option really...
                                            The <base target="_blank"> tag will work. Add it in to where it needs to be. On my wordpress blog, it is inserted in the index_sidebar.html and the post_sidebar.html. But then again, I don't mind going in and editing a couple lines of code to add a link so I can have my site act the way I want.
                                            Sample:

                                            <div id="menu">
                                            <ul>
                                            <li id="recentposts">Recent Posts
                                            {recentposts mode="list"}
                                            </li>

                                            <li id="categories">Categories:
                                            {sectionlinks mode="list" skip=10}
                                            </li>
                                            </ul>
                                            <ul>
                                            <li id="Links">Links
                                            <ul>
                                            Hand coded links to open in same window are below here!
                                            then...
                                            <base target="_blank">
                                            <li id="Pornblog">Porn Blogs
                                            <ul>
                                            and hand coded links for links I want to open in new window go here!
                                            Trades and Exchanges
                                            Submit to XXX Blog Index Growing Daily
                                            XXX Blog Maniac Hardlinks
                                            Battlin Bitchs Hardlinks and Traffic Trades
                                            XXX Blog Feeds

                                            Comment

                                            • nico-t
                                              emperor of my world
                                              • Aug 2004
                                              • 29903

                                              #23
                                              ^^ nice explanation, gonna try this tomorrow, thanks man

                                              Comment

                                              • Orange Sim
                                                Registered User
                                                • May 2005
                                                • 12

                                                #24
                                                You can't do that in CSS.
                                                You are mis-understanding what CSS is for and what it does.

                                                Cascading Style Sheets (CSS) is a simple mechanism for adding style (e.g. fonts, colors, spacing) to Web documents.

                                                Comment

                                                • nico-t
                                                  emperor of my world
                                                  • Aug 2004
                                                  • 29903

                                                  #25
                                                  misterwalrus, just put that base target code in my blog and it works perfect, thanks!

                                                  Comment

                                                  • SGS
                                                    Confirmed User
                                                    • Dec 2002
                                                    • 5176

                                                    #26
                                                    Originally posted by misterwalrus
                                                    The <base target="_blank"> tag will work. Add it in to where it needs to be. On my wordpress blog, it is inserted in the index_sidebar.html and the post_sidebar.html. But then again, I don't mind going in and editing a couple lines of code to add a link so I can have my site act the way I want.
                                                    Sample:

                                                    <div id="menu">
                                                    <ul>
                                                    <li id="recentposts">Recent Posts
                                                    {recentposts mode="list"}
                                                    </li>

                                                    <li id="categories">Categories:
                                                    {sectionlinks mode="list" skip=10}
                                                    </li>
                                                    </ul>
                                                    <ul>
                                                    <li id="Links">Links
                                                    <ul>
                                                    Hand coded links to open in same window are below here!
                                                    then...
                                                    <base target="_blank">
                                                    <li id="Pornblog">Porn Blogs
                                                    <ul>
                                                    and hand coded links for links I want to open in new window go here!

                                                    Best way of doing it
                                                    See sig...

                                                    Comment

                                                    • misterwalrus
                                                      Confirmed User
                                                      • Jan 2001
                                                      • 270

                                                      #27
                                                      Originally posted by nico-t
                                                      misterwalrus, just put that base target code in my blog and it works perfect, thanks!
                                                      Glad to help!
                                                      Trades and Exchanges
                                                      Submit to XXX Blog Index Growing Daily
                                                      XXX Blog Maniac Hardlinks
                                                      Battlin Bitchs Hardlinks and Traffic Trades
                                                      XXX Blog Feeds

                                                      Comment

                                                      Working...