www.webdeveloper.com
Results 1 to 3 of 3

Thread: Automatic link target?

  1. #1
    Join Date
    Feb 2007
    Posts
    2

    Automatic link target?

    We all know in <a> tags, we can add target="_blank". But is there a way to automatically set links to open in a new window, by putting a separate code in the header/body? Any help would be appreciated.

  2. #2
    Join Date
    Nov 2002
    Location
    Baltimore, Maryland
    Posts
    12,270
    Quote Originally Posted by Infamous JC
    We all know in <a> tags, we can add target="_blank".
    That's not such a great way to do things. Better to use JavaScript:
    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

  3. #3
    Join Date
    Feb 2007
    Posts
    2
    Okay.. where do I put this? ;p

    Edit : Nevermind, I got it. Thanks

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