Window.open resizes to the available width and height

I searched a little, but I donโ€™t see if this is possible or not. I would like to use the window.open() method to open links to the available window widths and heights. Something similar to the code below.

 var h = $(window).height(); var w = $(window).width(); $('#window-opener').live('click',function (e) { window.open(this.href, 'Resource', 'toolbar=no ,location=0, status=no, titlebar=no, menubar=no, width='+w', height='+h); e.preventDefault(); }); 

Is it possible? If no one can recommend a way to do something like this.

+4
source share
2 answers

Your code is correct, but missing after width concatenation:

 width='+w', 

it should be

 width='+ w +', 

I tried this, maybe I donโ€™t understand, I want you to really want:

 var h = screen.height; var w = screen.width; $('#window-opener').live('click',function (e) { window.open(this.href, 'Resource', 'toolbar=no ,location=0, status=no,titlebar=no,menubar=no,width='+w +',height=' +h); e.preventDefault(); });โ€‹ 

Fiddle: http://jsfiddle.net/UC8Ww/

+5
source

because you are not creating the string correctly.

 width='+w',height='+h); 

Do you see what you missed? I hope you see the missing +

+2
source

Source: https://habr.com/ru/post/1447956/


All Articles