Make all links in a dataTable open in a new tab/window?

Make all links in a dataTable open in a new tab/window?

mchughmchugh Posts: 2Questions: 1Answers: 0
edited October 2017 in Free community support

I've tried all the usual jquery methods of doing this, but none seem to affect the links within a DataTable.

Is there a known way of doing this?

I'm using the "Inline Google Spreadsheet Viewer" plugin for WordPress, which uses DataTables for display.

I have a column of URLS, which are made links, but want to add a target="_blank" to all or otherwise open a new tab/window when the links are clicked.

Answers

  • tangerinetangerine Posts: 3,365Questions: 39Answers: 395

    How are you creating the URLs? That would be the obvious time to add the "target" attribute.

  • mchughmchugh Posts: 2Questions: 1Answers: 0

    The "Inline Google Spreadsheet Viewer" plugin for WordPress automatically makes a column of URLs into HTML links, but there's no target.

    I've also posted in its support forum for a possible solution as well.

    I was mainly just wondering if anyone knew of a way via JS of applying the targets after the fact that would work, if all else fails.

  • allanallan Posts: 63,552Questions: 1Answers: 10,477 Site admin

    The "Inline Google Spreadsheet Viewer" plugin for WordPress automatically makes a column of URLs into HTML links, but there's no target.

    This isn't something that DataTables will address in that case.

    However, you could use something like:

    $('#myTable a').attr('target', '_blank');
    

    That's really more of a generic Javascript question for StackOverflow kind of thing rather than DataTables specific though.

    Allan

This discussion has been closed.