[SalesForce] How to pass the parameters from VF Page into Lightning Component

I am creating the lightning component with a leaflet map and access via Visualforce page. In that page created the drop down with contact list. Based on list value i select what are records set the Location ( Latitude and Longitude ) the map will refresh.

I have doubt how to pass the parameter of the list values into the lightning component. Guide me how to achieve this

This Error I got Using the 'Firing Lightning Events from Non-Lightning Code ' Method:

Uncaught SecurityError: Blocked a frame with origin "https://lightnapp-dev-ed–c.ap2.visual.force.com" from accessing a frame with origin "https://lightnapp-dev-ed.my.salesforce.com". Protocols, domains, and ports must match.

My Vf Page Code:

<apex:includeLightning /> 

    <div id="lightning" >    

<script>

   var myExternalEvent;      
   if(window.opener.$A && (myExternalEvent = window.opener.$A.get("e.c:ContactsSelected"))) {
     myExternalEvent.setParams({});
     myExternalEvent.fire();
   }    

   var visualForceFunction = function(event){
        //alert('function test')
        var EventData = event.getParam("auragl");            
        console.log('::::::::::::',EventData);
    }; 

    $Lightning.use("c:ContactLocatorApp", function() {
      $Lightning.createComponent("c:ContactLocator",
      { },
      "lightning",
      function(cmp) {          
        $A.eventService.addHandler({ "event": "c:ContactsSelected", "handler" : visualForceFunction});
        //alert('handler test');
      });
    });
</script> 
<apex:form >
  <apex:selectList size="1">
      <apex:selectOptions value="{!ContactsList}" />
      <!-- <apex:actionSupport event="onchange" oncomplete="function(this)"/>-->
  </apex:selectList>

Thanks

Best Answer

Probably you'll find an answer there:

"For the same-origin policy every browser blocks any script trying to access a frame with a different origin... Protocol, hostname and port must be the same of your domain, if you want to access a frame". SecurityError: Blocked a frame with origin from accessing a cross-origin frame

Related Topic