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.
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.
Share Improve this question asked Nov 23, 2012 at 14:01 devdev 4,0093 gold badges25 silver badges36 bronze badges 1- Have you tried it? Move your var declarations into the function and you should be good to go. – Jay Blanchard Commented Nov 23, 2012 at 14:21
2 Answers
Reset to default 10Your 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/
because you are builing your string wrong.
width='+w',height='+h);
Do you see what you missed? Hopefully you see the missing +