opening Links in new window

Discussion in 'HTML & Website Design' started by chosenlight, Oct 28, 2008.

  1. #1
    is there an html code or a javascript code that makes all html pages open in a new window. Not something that I need to input for new pages. This is because i have an established website and i want all the windows open in a new window so that they don't leave the site. I figure putting something in the head tag would be faster an easier than manually changing each and every single link.

    I know people will ask about my internal links. My internal links are on a the side menu which is on a different file (I use ColdFusion).

    Thanks in advance
     
    chosenlight, Oct 28, 2008 IP
  2. arizona39

    arizona39 Well-Known Member

    Messages:
    622
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    108
    #2
    yea its in the html code

    i dont remember off the top of my head

    but while its <a href="http://www.Google.com target="_blank">Google</a> target blank opens a new window i think
     
    arizona39, Oct 28, 2008 IP
  3. chosenlight

    chosenlight Active Member

    Messages:
    363
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    58
    #3
    Thanks but please read my original post...i know how to make a link open in a new window, i need a code that makes ALL links open in a new window on a particular page
     
    chosenlight, Oct 28, 2008 IP
  4. SearchBliss

    SearchBliss Well-Known Member

    Messages:
    1,899
    Likes Received:
    70
    Best Answers:
    2
    Trophy Points:
    195
    Digital Goods:
    1
    #4
    I would recommend not doing this. It's annoying when windows keep opening. It will not keep your visitors...what it will do is bother them enough never to return.
     
    SearchBliss, Oct 28, 2008 IP
  5. chosenlight

    chosenlight Active Member

    Messages:
    363
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    58
    #5
    Thanks, i dont mean to be rude, but i am not asking for advice i am asking for technical assistance
     
    chosenlight, Oct 28, 2008 IP
  6. SearchBliss

    SearchBliss Well-Known Member

    Messages:
    1,899
    Likes Received:
    70
    Best Answers:
    2
    Trophy Points:
    195
    Digital Goods:
    1
    #6
    Well I would take the advice.
     
    SearchBliss, Oct 28, 2008 IP
    kk5st likes this.
  7. kk5st

    kk5st Prominent Member

    Messages:
    3,497
    Likes Received:
    376
    Best Answers:
    29
    Trophy Points:
    335
    #7
    Well, if you just insist on doing something silly, add this to your head area.
    
    <script type="text/css">
    window.onload = function() {
        var links = document.getElementsByTagName("a");
        for (var i = 0; i < links.length; i++) {
    	links[i].onclick = function() {
    	    return !window.open(this.href);
    	}
        }
    }
    </script>
    Code (markup):
    cheers,

    gary
     
    kk5st, Oct 29, 2008 IP