removing target=_blank from links that are set to external scope

Post here questions and problems related to editing and publishing DITA content.
mdslup
Posts: 167
Joined: Tue Mar 06, 2018 1:34 am

removing target=_blank from links that are set to external scope

Post by mdslup »

I have some xrefs that point to a place somewhere else on the server, using "../../OtherFolder/File.html" notation. Everything works fine. However, I really don't want these opening in a new tab...however, Oxygen seems to want to add the target=_blank in the HTML to anything that has scope = external in the XML. How can I change this?
mihai_coanda
Posts: 78
Joined: Wed Jul 20, 2016 8:22 am

Re: removing target=_blank from links that are set to external scope

Post by mihai_coanda »

Hello,

To achieve your goal you can use sync.api.Editor.EventTypes.LINK_OPENED like in the following snippet:

Code: Select all

  goog.events.listen(workspace, sync.api.Editor.EventTypes.LINK_OPENED, function(e) {
    if(e.external) {
      e.linkTarget = sync.api.Editor.LinkOpenedEvent.Target.SELF;
    }
  });
You might want to better tune the detection of links that should opened in the current tab according to your usecase.

Best Regarda,
Michael
Michael

https://www.oxygenxml.com
Post Reply