By default, WebViewer opens links in documents in another tab. If you wish for links to open in the same window that WebViewer is in:
WebViewer(/*...*/).then(instance => {
// Assumes WebViewer 8.0+
const { Annotations } = instance.Core;
const createInnerElement = Annotations.Link.prototype.createInnerElement;
Annotations.Link.prototype.createInnerElement = function() {
const button = this;
const el = createInnerElement.apply(this, arguments);
el.addEventListener('mouseup', () => {
window.open(button.actions['U'][0].uri, '_self');
});
return el;
};
});