I am trying to send an Array to an Iframe, in another thread I was directed to event.Data and it works! But only with a single number and not multiple.
This is my code in the I frame(I am making a Chart with Chart.js):
<canvas id="myChart"></canvas>
<script src="https://cdn.jsdelivr. net/npm/chart.js@2.8.0"></script>
<script>
//on Message recived of Button (When Button pressed)
window.onmessage = (event) => {
event.data
var ctx = document.getElementById('myChart').getContext('2d');
var chart = new Chart(ctx, {
// The type of chart we want to create
type: 'line',
// The data for our dataset
data: {
labels: ['January', 'February', 'March', 'April', 'May', 'June', 'July'],
datasets: [{
label: 'My First dataset',
backgroundColor: 'rgb(255, 99, 132)',
borderColor: 'rgb(255, 99, 132)',
data: [ event.data ]
}]
},
// Configuration options go here
options: {}
});
}
</script>
And this is the code in a button, which loads the chart:
$w.onReady(function() {
$w('#button1').onClick(function() {
$w("#html1").postMessage(10);
})
})
That’s as far as I can get it to work, but I still want an Array sent.
Thank you!