window.open size and place

Asked

Viewed 2,115 times

1

I am using windows.open to open wanted it to open like one of the popads in the bottom right corner and decide to use the code such but it n decreases in size and n stays in the right cando like someone could help me follow the code I used

<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>

Imagem de colo queria e n estou conseguindo

  • 1

    I didn’t understand a thing

  • when I use the code above it opens a window and a size but n is the same as the one of ft q is well in the right corner and very small and wanted it to be the same

  • Your question is very badly formatted. Give an improved in Portuguese and accent to understand what you want.

1 answer

1


Do not use values in % in the size of popup because the method can’t stand it. Use only values in pixels (without the px).

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

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.
}

Browser other questions tagged

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