www.webdeveloper.com
Results 1 to 8 of 8

Thread: One Tag To Open Every Link In A New Window?

  1. #1
    Join Date
    Jun 2006
    Posts
    4

    One Tag To Open Every Link In A New Window?

    I'm asking about my Myspace account. I'd like to know if there's one piece of code
    that i can put in that will allow all links clicked from my site to open and load in a new page.

    Thanx in advance.

  2. #2
    Join Date
    Aug 2005
    Location
    Bristol, England
    Posts
    125
    Sure

    <a href="http://www.link.com" target"_blank">Link</a>

  3. #3
    Join Date
    Jun 2006
    Posts
    4
    Well I know about that... but i'm trying to keep from not putting that behind every single link...

    In other words isn't there something that would say links 1 2 3 4 & 5 will open in new windows when

    1

    2
    pic

    3
    text
    4

    5

    because i can't control all the html on my page... if someone clicks on someone else's profile from mine, it'll open in the same window, and i'm trying to change that

  4. #4
    Join Date
    Nov 2002
    Location
    Baltimore, Maryland
    Posts
    12,270
    Sure, there's lots of ways to do this.

    Do you want all of the links to open in a new window?

    If so, can you edit the document's HEAD element.

    If not, are they all in one section?
    “The power of the Web is in its universality. Access by everyone regardless of disability is an essential aspect.”
    —Tim Berners-Lee, W3C Director and inventor of the World Wide Web

  5. #5
    Join Date
    Jun 2006
    Posts
    4
    Yes, that's what i'm trying to accomplish... ALL THE LINKS
    Except the catch is, it's myspace so i don't have complete control over all the html. I am able to change the way it looks by adding this code to a section, and i want to add something to open a new window evertime any and every link is clicked... maybe i'm dreaming

    <Style type="text/css"> body{ background-color:333333; } Table, Td{ background-color:transparent; } body, div, p, strong, td, .text, .blacktext10, .blacktext12, a.searchlinkSmall, a.searchlinkSmall:link, a.searchlinkSmall:visited{ color:FFFFFF; font-size:10pt; font-weight:bold; font-style:italic ; font-family:Arial, verdana, arial, sans-serif; } </Style>

  6. #6
    Join Date
    Nov 2002
    Location
    Baltimore, Maryland
    Posts
    12,270
    Well if you can add a STYLE element to the HEAD then you should be able to add a BASE element.
    HTML Code:
    <base target="_blank">
    Otherwise you might try a little JavaScript.
    HTML Code:
    <script type="text/javascript">
    onload = function () {
      var l, i = 0
      while (l = document.links[i++]) {
        l.onclick = function () {window.open (this.href, 'child'); return false}
      }
    }
    </script>
    “The power of the Web is in its universality. Access by everyone regardless of disability is an essential aspect.”
    —Tim Berners-Lee, W3C Director and inventor of the World Wide Web

  7. #7
    Join Date
    Jun 2006
    Posts
    4
    Oh man that so totally almost works thanx a lot!!

    it works on all the links except when people go to click my pic for more pics

  8. #8
    Join Date
    Jun 2004
    Location
    England
    Posts
    2,972
    Funny that, it looks like a regular link. I think you've reached the point where you have to accept that myspace is screwy and not everything is going to work the way you want it to.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles