Open link in new tab directly in the Ink array

Asked

Viewed 82 times

0

How can I apply the attribute target=_blank directly in the array below?

arrayLink[1]="https://url/cart.php?a=add&pid=00";

I can’t apply to HTML.

Follow function executed via onclick:

function buyVps(){
                var vpsDetails='Processor : '+arrayProcessor[sliderValue]+' GHZ'+'\nRAM : '+arrayRam[sliderValue]+' MB'+'\nRAID Storage : '+arrayStorage[sliderValue]+' GB'+'\nMySql Databases : '+arrayMySqlDB[sliderValue]+' GB'+'\nMonthly Price : '+'R$ '+arrayAmount[sliderValue];window.location.href=arrayLink[arrayBlocks[sliderValue]];
            };

1 answer

2


The window.location.href redirects your local tab to the new desired url. To do what you want, we should use the function window.open. Would look like this:

function buyVps(){
    var vpsDetails='Processor : '+arrayProcessor[sliderValue]+' GHZ'+'\nRAM : '+arrayRam[sliderValue]+' MB'+'\nRAID Storage : '+arrayStorage[sliderValue]+' GB'+'\nMySql Databases : '+arrayMySqlDB[sliderValue]+' GB'+'\nMonthly Price : '+'R$ '+arrayAmount[sliderValue];

    window.open(arrayLink[arrayBlocks[sliderValue]], '_blank');
};

Browser other questions tagged

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