In this blog I will show you how you may communicate between LWC to VF page and vice versa.
Visualforce page and Lightning Components can coexists, while communicating between them you need to take care of few things.
Different DOM Elements : As the visualforce page will be in an iframe so the DOM elements of the Lightning Component and VF page will be different. And also the window object will be separate for VF page.
Different Origin : Visualforce page and Lightning Components are having their different origins. For lightning component it will be ending with lightning.force.com and for visualforce pages it will be ending with visualforce.com
Now the question is why it's difficult to communicate with different origin pages?
Answer : It is due to browsers Same Origin Policy, this prevents page to pass or receive code/data from a different origin page.
This is due to security reasons. But fortunately we are having an API to do this securely.
To do this we will be using window.postMessage()
#Salesforce #lwc #Visualforce
Join me on Instagram : / iamkapilbatra
Blog : www.salesforce...
Website : www.salesforce...
LinkedIn : / salesforcebolt
Twitter : / salesforcebolt
Facebook : / iamsalesforcebolt
Негізгі бет Communication between Lightning Web Component and Visualforce Pages in Salesforce | LWC Stack ☁️⚡️
Пікірлер: 4