Page 1 of 1
removing target=_blank from links that are set to external scope
Posted: Thu Jan 06, 2022 8:14 am
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?
Re: removing target=_blank from links that are set to external scope
Posted: Fri Jan 07, 2022 11:29 am
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