Relative Links

137 views
Skip to first unread message

David Collins

unread,
Apr 29, 2016, 2:16:16 PM4/29/16
to PDFTron WebViewer
I have hyperlinks in my converted XODs that are external to the XOD, but in the same site. Ideally, they would be relative URLs so I don't have to update the XOD in the various staging environments, but I can only get absolute URLs to work.  I thought I could handle the click event of the link and append the baseURL of the site, but I am having no luck.  I have found past discussions referencing a linkReady event, but it never seems to fire.   I have tried it in the viewerLoaded event, (which fires before my custom config loads) and in the documentLoaded event.  Any assistance would be appreciated.  I am using WebViewer version 2.2. 

Thanks,
David Collins

Matt Parizeau

unread,
May 5, 2016, 9:03:58 PM5/5/16
to PDFTron WebViewer
Hi David,

In WebViewer 2.1 and up links use URI actions and you can override the onTriggered event for URI actions like the following:
Actions.URI.prototype.onTriggered = function() {
 
Actions.Action.prototype.onTriggered.apply(this, arguments);
  window
.open('http://myurl.com/' + this.uri);
};

Matt Parizeau
Software Developer
PDFTron Systems Inc.

David Collins

unread,
Aug 10, 2016, 6:43:42 PM8/10/16
to PDFTron WebViewer
Matt:

Thank you for the reply on this issue from earlier.  The snippet you posted was just what I was looking for, however in doing some additional testing I'm noticing that the action is not triggered on a device with a touch screen, which is using the mobile version of the viewer.  Comparing ReaderControl.js and MobileReaderControl.js, it looks like the same event is not available.  Is there someway to handle this situation with the mobile viewer?

Regards,
David

David Collins

unread,
Aug 11, 2016, 1:03:39 PM8/11/16
to PDFTron WebViewer
I should clarify that the original code snippet does work in the mobile viewer when responding to a mouse click, it just does not seem to be triggered by touch events.

Thanks,
David

On Friday, April 29, 2016 at 1:16:16 PM UTC-5, David Collins wrote:

David Collins

unread,
Aug 11, 2016, 5:11:48 PM8/11/16
to PDFTron WebViewer
I must apologize, the code is working now, and I am not sure why.  I have a web app manifest with display set to stand-alone and it seemed to be isolated to that case.  It seems to work more reliably with display mode set to full screen.


On Friday, April 29, 2016 at 1:16:16 PM UTC-5, David Collins wrote:
Reply all
Reply to author
Forward
0 new messages