Calling the same function twice

Asked

Viewed 605 times

0

I am testing a function that opens pop-up for certain link, and would like to call it to 2 links then basically your 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, but it only works with the last URL of the array, as if I rewritten all previous calls, how can I call the same function 2 times? as if it were 2 different places in memory.

  • 1

    That one jsPopunder only allows 1 pop-up each time?

  • Unfortunately I found the script on the net, has no documentation apparently yes.

3 answers

1

as you did not give details about the script jsPopunder.

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

[
  'http://google.com',
  'http://answall.com',
  'http://example.com'
].forEach(jsPopunder);

1

Take a look at this fiddle: jsFiddle

Opens 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');
  });
});

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>

Browser other questions tagged

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