I need to create a button using a lightning aura component that will open VisualForce page in a new tab.

I wonder is there a way to do it?

Thank you,

  • Salesforce actively fights against you when it comes to making new tabs to keep you within the Lightning framework, so there isn't navigation event you can use to do that. That said, window.open(myUrl, '_blank'); works just fine.
    – nbrown
    Jan 22 at 0:52

Just render a code block containing iframe with your vf page as the source Something like this

<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes,force:hasRecordId" access="global">
    <iframe src="{! 'https://my-demo.visual.force.com/apex/MyVisualforcePage?Id=' + v.recordId }" width="100%" height="500px;" frameBorder="0"/>

Just preview your vf page copy the url to iframe source

Note: Prod,sandbox have different domain urls' later on make sure you make the domain name in URL dynamic. And incase the page instead of opening auto dowloads just make sure you change the behaviour of iframe in setup...

this will cause an overlay ..kind of a modal when used in quick actions and in lightning component you may need to create the modal...

and using javascript there's always

window.open(vfURL, '_blank');

Uses the same vf url we are using in iframe ..

  • Thanks, it is really helpful
    – olgaK
    Jan 23 at 18:51
  • if it works do accept the answer it will help others to Jan 27 at 15:17

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.