Using the <a href=full URL target=_blank>URL</a>
tag we can pass the URL
in span
tag and added the attribute title which is the attribute HTML uses as the default for mouse-overs. Here how we can use the span
tag:
<a href=full URL target=_blank> <span title= full URL > Short URL </span> </a>
Then we will use JS to display a reasonable length for span
in data.table
in this case will be 30
library(DT)
datatable(data.frame(URLs), options = list(columnDefs = list(list(
targets = c(1),
render = JS(
"function(data, type, row, meta) {",
"return type === 'display' && data.length > 30 ?",
"'<a href=\"' + data + 'target=\"_blank\"> <span title=\"' + data + '\">' +
data.substr(0, 30) + '...</span></a>' : data;",
"}")
))))
Data
URLs <- c("http://127.0.0.1:4534/?_inputs_&bookmarkName=%2211m%22&budget_input=11000000&col=%22table%22&col1=%22bud_digi_table%22&drop624996478=1&drop624996478_state=true&inp_lb=0.5&inp_ub=1.5&iterations=2000&myNavbarPage=%22Optimizer%22&opt_reset=0&opt_run=0
", "http://127.0.0.1:4534/?_inputs_&bookmarkName=%2211m%22&budget_input=11000000&col=%22table%22&col1=%22bud_digi_table%22&drop624996478=1&drop624996478_state=true&inp_lb=0.5&inp_ub=1.5&iterations=2000&myNavbarPage=%22Optimizer%22&opt_reset=0&opt_run=0
")