From version < 3.1 >
edited by Gunter Ohrner
on 2019/06/26
To version < 4.1 >
edited by Gunter Ohrner
on 2019/06/26
< >
Change comment: There is no comment for this version

Summary

Details

FAQCode.FAQClass[0]
answer
... ... @@ -17,4 +17,4 @@
17 17  {{/code}})))
18 18  1. Set //Use this extension// to //On this wiki//.
19 19  
20 -Thanks to [[laurin1>>https://forum.xwiki.org/u/laurin1]] for this [[solution>>https://forum.xwiki.org/t/solved-external-links-set-default-target-as--blank/2583/21]].
20 +Thanks to [[pdwalker>>https://forum.xwiki.org/u/pdwalker]] and [[laurin1>>https://forum.xwiki.org/u/laurin1]] for this [[solution>>https://forum.xwiki.org/t/solved-external-links-set-default-target-as--blank/2583/21]].

In order to configure all external links to open in new tabs / windows automatically, i.e. to use the link target "_blank" from an HTML point of view, you have to add some JavaScript to your XWiki:

  1. Create a new page, or go to an existing page that won’t be removed
  2. Click Edit and select Objects.
  3. In the Select a Class box, select JavaScriptExtension and click the Add button.
  4. In the object that just appeared, enter the following code into the Code box:
    function fixExternalLinks() {
     var nodes = document.querySelectorAll('.wikiexternallink a');
     for(var i=0; i< nodes.length; i++){
       var link = nodes[i];
       if (link.hasAttribute('target') == false)  {
          link.setAttribute('target', '_blank');
        }
      }
    }
  5. Set Use this extension to On this wiki.

Thanks to laurin1 for this solution.

Thanks to pdwalker and laurin1 for this solution.

Get Connected