Timeline for Lightning Web component and Visual force page communication behave differently in browsers and the sending signal from VF to LWC does not work
Current License: CC BY-SA 4.0
13 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Jun 21, 2021 at 2:28 | comment | added | Isuru Buddhika Herath | you could add this as a answer, your comment saved me literally two three days. | |
Dec 19, 2019 at 21:01 | comment | added | Minh | Just update to my own questions: - the reason Chrome did not receive communication from LWC to VF is because the debug mode is turned on on the VF Page. As long as I turn that debug mode off, the LWC can send message to VF in Chrome. Regard to the reverse sending message from VF to LWC, I use Aura component code as the middle man for communication. | |
Nov 22, 2019 at 19:18 | history | edited | Minh | CC BY-SA 4.0 |
added 1897 characters in body
|
Nov 22, 2019 at 19:10 | history | edited | Minh | CC BY-SA 4.0 |
added 1897 characters in body
|
Nov 22, 2019 at 18:27 | comment | added | Minh | By the way, when I tried the postMessage from VF to LWC, I also had this error "testPage?core.apexpages.devmode.url=1:20 Failed to execute 'postMessage' on 'DOMWindow': The target origin provided ('abc--minh.lightning.force.com') does not match the recipient window's origin ('abc--minh--c.cs2.visual.force.com')". | |
Nov 22, 2019 at 18:24 | comment | added | Minh | To ========== to [this.template.addEventListener('message', this.updateMessage.bind(this)); updateMessage(){ alert("We are here"); } ]=============== Then there is no error in the console any more. Do you think the "function(event)" is not correct? | |
Nov 22, 2019 at 18:24 | comment | added | Minh | I did try to use this.addEventListener but it still have the error. However, if I change the code ==== this.template.addEventListener('message', function(event) { alert("from VF connnect" + event); if (event.origin !== origin) { // Not the expected origin: Reject the message! return; } else{ this.messageFromVF = event.data; } // Handle the message alert("from VF connect" + event.data); }, false);=================================== | |
Nov 22, 2019 at 17:52 | comment | added | Bryan Anderson |
I think you may just want to use this.addEventListener in your LWC controller
|
|
Nov 22, 2019 at 17:38 | comment | added | Minh | Thus I guess the addEvenListener method is not accepted by the JS controller for Chrome browser? | |
Nov 22, 2019 at 17:37 | comment | added | Minh | Something wrong with my Edge browser too, I could not see the dev console after pressing F12. It just disappeard :( | |
Nov 22, 2019 at 17:35 | comment | added | Minh |
Thanks @BryanAnderson, Below is the error that I saw when I load the App in Chrome console: aura_proddebug.js:214 Error: [LWC error]: The addEventListener method in LightningElement does not support any options. <c-test-communication-l-w-c> at Object.logError (aura_proddebug.js:210) at addShadowRootEventListener (aura_proddebug.js:716) at DocumentFragment.value [as addEventListener] (aura_proddebug.js:1362) at DocumentFragment.value [as addEventListener] (aura_proddebug.js:6025) at new TestCommunicationLWC (testCommunicationLWC.js:72)
|
|
Nov 22, 2019 at 16:45 | comment | added | Bryan Anderson | In Edge's developer console, do you see any error messages when you perform this operation? | |
Nov 22, 2019 at 16:41 | history | asked | Minh | CC BY-SA 4.0 |