How do I pass a variable into a frame?

-1

Hello, how are you? I wanted to pass a variable that contains a result into a frame that contains a chart and then the chart would use that value and plot it on the chart.

I'm programming in Ionic 3, HTML, JavaScript and SCSS.

How do I get the variable that is in JavaScript and play within the frame that is loading in HTML?

    
asked by anonymous 18.08.2018 / 17:06

1 answer

0

This question already exists in the SO in English, but to facilitate your understanding I will give a translated

On the page where the iframe will appear:

function myFunction(){
$('#meuIframe').attr('src', "meuIframe.html?param1=value1&param2=value2"); 
}

Inside your iframe:

function getParamValue(paramName) {
    var url = window.location.search.substring(1); // Pega as variaveis na url
    var qArray = url.split('&'); // pega os pares de chave e valores
    for (var i = 0; i < qArray.length; i++) {
        var pArr = qArray[i].split('='); // Separa a Chave do Valor
        if (pArr[0] == paramName) 
            return pArr[1]; // Retorna o Valor
    }
}

If you want to get a specific parameter use:

var param1 = getParamValue('param1');

Original post link

Credits: Ozgur Bar

    
18.08.2018 / 17:21