window.open size and place

1

I'm using windows.open to open it wanted to open it equal one of the popads in the bottom corner of the right side and resolve to use such code but it n decreases in size and it stays in the right cando same someone could help me follow the codico q usedi

<script>
document.onclick = function(e){
    myFunction();
}

function myFunction(){
    window.open("http://google.com", "_blank", "toolbar=false, scrollbars=false,resizable=false, top=900, left=5000, width=300, height=4%");
    document.onclick = null; // anulando na próxima execução.
}
</script>

    
asked by anonymous 03.02.2018 / 02:10

1 answer

1

Do not use values in % in popup size because the method does not support a>. Use only values in pixels (without px ).

Assuming a popup of 300x200, to open in the lower right corner, use as the basis of calculation the dimensions of the window decreasing the values by the popup size in the% and top :

document.onclick = function(e){
   myFunction();
}

function myFunction(){

   var lar_janela = window.innerWidth;
   var alt_janela = window.innerHeight;

   console.log(alt_janela);
   window.open("http://google.com", "_blank", "toolbar=false, scrollbars=false,resizable=false, top="+(alt_janela-200)+", left="+(lar_janela-300)+", width=300, height=200");
   document.onclick = null; // anulando na próxima execução.
}
    
03.02.2018 / 03:06