Window.open调整大小为可用的宽度和高度

dev*_*dev 5 javascript jquery fullscreen window.open

我做了一些搜索,但我不知道这是否可能.我想使用该window.open()方法打开窗口可用宽度和高度的链接.类似于下面的代码.

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();
});
Run Code Online (Sandbox Code Playgroud)

这可能吗?如果没有,任何人都可以推荐一种类似的方法.

phe*_*atd 7

你的代码是正确的,在宽度连接之后只缺少'':

width='+w', 
Run Code Online (Sandbox Code Playgroud)

一定是

width='+ w +', 
Run Code Online (Sandbox Code Playgroud)

我试过这个,也许我不明白你真的想做什么:

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();
});?
Run Code Online (Sandbox Code Playgroud)

小提琴:http://jsfiddle.net/UC8Ww/