Call the same function twice

0

I'm testing a function that pops up for a given link, and I would call it for 2 links then basically its call is like this:

jsPopunder(URL);

I tried to create an array with the URLs and call the function using a loop according to the quantity, however it only works with the last URL of the array, as if it had rewritten all the previous calls, how can I call it function 2 times? as if it were 2 different places in memory.

    
asked by anonymous 04.06.2017 / 20:45

3 answers

1

As you did not give details about the jsPopunder script.

var jsPopunder = function (url) {
  window.open(url);
};

[
  'http://google.com',
  'http://pt.stackoverflow.com',
  'http://example.com'
].forEach(jsPopunder);
    
04.06.2017 / 21:05
1

Take a look at this fiddle: jsFiddle

Open the popup's according to the number of items in the array:

var arr = ["http://www.google.com", "https://www.stackoverflow.com/"];

$("#links").click(function() {
  arr.forEach(function(e) {
    window.open(e, e, 'width=500,height=500');
  });
});
    
04.06.2017 / 21:08
0

To open popups in different places on the page

function jsPopunder() {
    window.open("http://www.google.com","PAGINA1",'scrollbars=no,width=235,height=155,left=100,top=200,screenX=100,screenY=200');
    window.open("https://www.stackoverflow.com/","PAGINA2",'scrollbars=no,width=235,height=155,left=1000,top=200,screenX=1000,screenY=200');
    //window.open("http://www.dominio.com/","PAGINA3",........
    //window.open("http://www.dominio.com/","PAGINA4",........
}

HTML

<button onclick="jsPopunder()">Abrir</button>
    
04.06.2017 / 21:35