Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Window.open resize to available width and height

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.

like image 647
dev Avatar asked Nov 23 '12 14:11

dev


People also ask

How do I stop a browser window from resizing after a specific size?

Prevent Browser Resize Css CSS can be used to prevent browser resizing. By using the max-width property, you can set a maximum width for the browser window. If the browser window is resized to be smaller than the max-width, the browser will automatically adjust the size of the elements on the page.

How do I resize a window in HTML?

The resizeTo() method is used to resizes a window to the specified width and height. Parameter Values: width: Sets the width of the window, in pixels. height: Sets the height of the window, in pixels.

How do I change the width and height of a popup window in HTML?

You can set height and width of your popup window by using window. resizeTo(preferedWidth, preferedHeight) function. If you want to set this inside a popup window not from parent window than self. resizeTo(preferedWidth, preferedHeight); will do the job for you.

Which of the following can be used to create a window by specifying the width and height?

The resizeTo() method resizes a window to a new width and height.


1 Answers

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/

like image 149
phemt.latd Avatar answered Sep 27 '22 22:09

phemt.latd