Question: hwriter or reportingtools: open link in new tab?
0
gravatar for Wade Davis
4.3 years ago by
Wade Davis60
USA
Wade Davis60 wrote:

Does anyone have a solution using either hwriter or ReportingTools such that by default the links in the HTML open in a new tab or window when selected?

Looking at hwrite(), it seems that if the "target" attribute was available as optional argument, I could pass it the value "_blank" and that would do the trick.

Or is there something in the CSS or ReportingTools that could be modified to make this happen?

Thanks,

Wade

ADD COMMENTlink modified 4.3 years ago • written 4.3 years ago by Wade Davis60
Answer: hwriter or reportingtools: open link in new tab?
0
gravatar for Andrzej Oleś
4.3 years ago by
Andrzej Oleś720
Heidelberg, Germany
Andrzej Oleś720 wrote:

Hi Wade,

the following JavaScript snippet does the trick of setting the target of external links to _blank.

document.addEventListener("DOMContentLoaded", function() {
  var links = document.links;  
  for (var i = 0, linksLength = links.length; i < linksLength; i++)
    if (links[i].hostname != window.location.hostname)
      links[i].target = '_blank';
});

This code is used in the BiocStyle package. The restriction to external links can be removed and the target of all links in the document modified by deleting the if clause.

Best,

Andrzej

ADD COMMENTlink written 4.3 years ago by Andrzej Oleś720
Answer: hwriter or reportingtools: open link in new tab?
0
gravatar for Wade Davis
4.3 years ago by
Wade Davis60
USA
Wade Davis60 wrote:

Hi Andrzej,

Thank you for speedy reply; it worked like a charm.

Just to summarize for others using ReportingTools, what I did was add this snippet

document.addEventListener("DOMContentLoaded", function() {
  var links = document.links;  
  for (var i = 0, linksLength = links.length; i < linksLength; i++)
      links[i].target = '_blank';
});

to the /jslib/jquery.dataTables.reprise.js file used by ReportingTools.

 

Thanks again,

Wade

 

 

ADD COMMENTlink written 4.3 years ago by Wade Davis60
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 16.09
Traffic: 214 users visited in the last hour