3

I've got a lightning:dataTable I'm working on for a client. One of the columns is of type URL, and it links to a Visualforce PDF. It is defined in the columns attribute as:

{
  sortable:true, 
  label: 'Invoice No.',
  fieldName: 'urlField__c',
  type: 'url' , 
  typeAttributes: { 
    label: { fieldName: 'Invoice_Number__c' }, 
    target:'_blank'
  }
}

When the component loads, I can "Inspect Element" in Chrome and see that the URL correctly has target=_blank. However clicking it always opens the PDF in the same window under the Lightning header instead of popping open a new one. Then the user has to hit the back button to return to where they were which is not intuitive.

Is there anything I can do to force it to a new window?

8
  • Could it be related to this bug someone else mentioned? salesforce.stackexchange.com/questions/157552/… Are the urls all relative urls? If so, does adding an underscore before the '/' make a difference?
    – Kyle
    May 2 '18 at 22:00
  • All relative URLs, yes, to a Visualforce PDF. I have not tried the underscore. In fact I ended up trying a bit of a silly hack... I changed the column to type "button", selected "base" so it appears like a link with no actual button, and then used an onrowaction handler. But I'll see if the underscore might help too.
    – Charles T
    May 3 '18 at 1:45
  • If I attempt to add a underscore to the field containing the URL, the browser no longer interprets it properly.
    – Charles T
    May 4 '18 at 18:09
  • And if I attempt to do it as an absolute URL link, that too opens in the same window.
    – Charles T
    May 4 '18 at 18:12
  • So I just tried testing this out in an org, and when I have a url field with target: '_blank' and a relative URL I get a modal popup that says "We'd like to open the Salesforce page https://[url here]... in a new tab. Because of your browser settings, we need your permission first. Is it possible you have popups completely blocked by your browser or other security software? One interesting thing is that when I cancelled the popup instead of accepting it, I started seeing the behavior you reported and clearing my browser data didn't cause the Salesforce modal to show up again.
    – Kyle
    May 4 '18 at 19:40
0

typeAttributes: {label: { fieldName: 'Invoice_Number__c' }, target: '_top'}},

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.