Javascript – Window.open resize to available width and height

fullscreenjavascriptjquerywindow.open

I've done a bit of searching but I can't see if this is possible or not. I would like to use the window.open() method to open links to the windows available width and height. Something similar to the below code.

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 this possible? If not can anybody recommend a way of doing something similar.

Best Answer

Your code is correct, only missing a ' after the width concatenation:

width='+w', 

must be

width='+ w +', 

I've tried this, maybe i don't understand want you really want to do:

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/