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.
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.
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.
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.
The resizeTo() method resizes a window to a new width and height.
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/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With