Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Oct 2009
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Open outside links in new window/tab?

    I have a blogger blog (http://www.thepinkpacifier.com) and I'm wondering if there's any way I can modify the template coding to make all the links leading off of the site automatically open in another window so that I don't have to put target=_blank in the link code every time.

    I don't want the links to my other blog posts and such to open in new windows, but I link to various baby products fairly often and I don't want to lead people away from my site.

    Thanks in advance^^

  • #2
    Senior Coder Rowsdower!'s Avatar
    Join Date
    Oct 2008
    Location
    Some say it's everything.
    Posts
    2,027
    Thanks
    5
    Thanked 397 Times in 390 Posts
    You can use javascript for this. You would need to test the URL for every link in the page to see if it is external and then, if it is, dynamically add the attribute of target="_blank" to the <a> tag.

    You could probably work out some PHP for this too, but that would be a pain.
    The object of opening the mind, as of opening the mouth, is to shut it again on something solid. –G.K. Chesterton
    See Mediocrity in its Infancy
    It's usually a good idea to start out with this at the VERY TOP of your CSS: * {border:0;margin:0;padding:0;}
    Seek and you shall find... basically:
    validate your markup | view your page cross-browser/cross-platform | free web tutorials | free hosting


  •  

    Tags for this Thread

    Posting Permissions

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