Is there an easy way to make all links load in a new browser tab?

  • 2
  • Question
  • Updated 2 years ago
  • Answered
I want to always keep my nice Skuid page with a reference table open, and when I click on record links I want them to open in a different/new tab. Is there any way to do this without manually overriding each column in my table with a template containing a custom URL?
Photo of Peter Bender

Peter Bender, Champion

  • 6,246 Points 5k badge 2x thumb

Posted 5 years ago

  • 2
Photo of ktyler

ktyler

  • 9,244 Points 5k badge 2x thumb
Peter,
Depending on your operating system/browser there is usually a key you can press to do this... on my mac, in chrome, its command + click on the link
Photo of Anna Wiersema

Anna Wiersema

  • 10,890 Points 10k badge 2x thumb
Hi Peter, you can try this at the page level by including this javascript snippet in your page.


(function(skuid){

var $ = skuid.$;

$(function(){

$('head').append(

$('<base target="_blank">')

);

});

})(skuid);
Photo of Shmuel Kamensky

Shmuel Kamensky, Champion

  • 4,328 Points 4k badge 2x thumb
Thanks so much!
Photo of Rowel Ventura

Rowel Ventura

  • 424 Points 250 badge 2x thumb
Woah! Thanks for sharing this! 
Photo of Rowel Ventura

Rowel Ventura

  • 424 Points 250 badge 2x thumb
Ohh it's working in classic but not in lightning
Photo of Peter Bender

Peter Bender, Champion

  • 6,246 Points 5k badge 2x thumb
I added this as a snippet on my page, but it didn't change the functionality of the links on my page. Links still open in the same tab.
Photo of Anna Wiersema

Anna Wiersema

  • 10,890 Points 10k badge 2x thumb
Also, you should use the Inspect Element feature on your browser to see if this code actually got correctly appended to your page.
Photo of Anna Wiersema

Anna Wiersema

  • 10,890 Points 10k badge 2x thumb
Hmm.... I just tried this as an Javascript Resource (type = in-line) and it worked fine.


(function(skuid){

var $ = skuid.$;
$(function(){
$('head').append(
$('base target="_blank"')
);
});
})(skuid);
(Edited)
Photo of Peter Bender

Peter Bender, Champion

  • 6,246 Points 5k badge 2x thumb
I see the following code in the script section of my rendered page, but the links still open in the same tab. Perhaps there's a browser setting that's overriding this?

(function(skuid){
var $ = skuid.$;
$(function(){
$('head').append(
$('base target="_blank"')
);
});
})(skuid);;
Photo of Anna Wiersema

Anna Wiersema

  • 10,890 Points 10k badge 2x thumb
ughhhh the code editor here is messing things up. it's supposed to be '<base target="_blank">'

is that what you had?
Photo of Peter Bender

Peter Bender, Champion

  • 6,246 Points 5k badge 2x thumb
No, it wasn't, but now I've changed it to to the following, and now it does work:
(function(skuid){
var $ = skuid.$;
$(function(){
$('head').append(
$('<base target="_blank">')
);
});
})(skuid);

Thanks!
Photo of Anna Wiersema

Anna Wiersema

  • 10,890 Points 10k badge 2x thumb
no problem! sorry for the confusion and glad it's working now!
Photo of Kaede Holland

Kaede Holland

  • 2,744 Points 2k badge 2x thumb
Should this work for the "On-Click URL" on photo views of a table?