How Do I Make Link Annotations Open In The Same Tab As WebViewer?

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;
  };
});

Hello, I’m Ron, an automated tech support bot :robot:

While you wait for one of our customer support representatives to get back to you, please check out some of these documentation pages:

Guides:APIs:Forums: