How do I move a variable into a frame?

Asked

Viewed 58 times

-1

Hey, how you doing? I wanted to pass a variable that contains a result into a frame that contains a graph and then the graph would use that value and plot in the graph.

I am programming in Ionic 3, HTML, Javascript and SCSS.

How do I take the variable that is in Javascript and play inside the frame that is loading in HTML?

1 answer

0

This question already exists in the OS 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 of 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 take a specific parameter use:

var param1 = getParamValue('param1');

Link to Original post

Credits: Ozgur Bar

  • var param1 = getParamValue('param1'); should I put in js and specify the variable I want to send? and this:: Function myFunction(){ $('#meuIframe'). attr('src', "meuIframe.html?param1=value1&param2=value2");?

Browser other questions tagged

You are not signed in. Login or sign up in order to post.