Links open in new window

URls aded to comments etc always open in a new window. Is there anyway to change this behaviour and let the user choose, so that links to other parts of the same site do not create new tabs/windows.

  • I can't think of any easy way to do this without customising the widgets with the comments other than something like this with Jquery:

    $('.comments a').each(function() {

      var a = new RegExp('/' + + '/');

      if(!a.test(this.href)) {

          $(this).click(function(event) {



    , '_self');




    You could perhaps create a setting in their profile to say "open links in a new window" true/false. Then you could render out different JS depending on what the user has selected.

    I haven't tested this but in theory I think it should work.

  • In reply to Adam Seabridge:

    Hi Adam

    Thanks for responding.

    What I meant was that the default across the web (should be for usability) to open links in the same window/tab.

    For each link the user can then choose to to open it in a new window if they want. Vice versa the user cannot choose to its bad to set target="blank".

    I'd not want to give them a profile setting. I'd want all links to have no target attribute.

    So you're saying each widget would have to be tweaked or it done with JavaScript?


  • In reply to James Buller:

    James, you could use Adam's code to apply to ALL Links by just modifying this line of code:

    $('.comments a').each(function() {  

    Change to:

    $('a').each(function() {

    You would want to test this to ensure everything works properly after you make the change.

  • In reply to Luke D:

    Downside to  $('a').each(function() {  is you are going make community links open in another browser window too and that wouldn't be good.  Its also going to potentially hit links that are controlled by javascript behavior.

    I don't have the code(would require some digging) but I would modify the code slightly to exlcude realtive links, links that are fully qualified to your site, and actually have an href set

  • In reply to Patrick Mason:

    Hi James, I am interested in your use case actually as most clients we work with want to ensure that their customers/users stay on their site as much as possible so would actually prefer the external links to open in a new window to ensure they always keep a tab with the community open so they can come back easily.

    It may be possible to make this change by customising widgets but using js is probably a easier/quicker route. As Patrick mentions you need to be careful with the js else you could affect other functionality on the site that you didn't mean to.