Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to resize a window using JQuery?

JQuery has an event called resize using which you can add an event handler when the window is resized e.g.

$(window).resize(function () {
// code here
});

What I'd need is to resize the window using a JQuery command; would that be possible?

e.g. $(window).resize(-1, -1); // to decrease/increase the width and height of the window

Thanks

like image 443
The Light Avatar asked Jul 15 '11 15:07

The Light


People also ask

How does jQuery determine window resize?

jQuery resize() MethodThe resize event occurs when the browser window changes size. The resize() method triggers the resize event, or attaches a function to run when a resize event occurs.

How do you trigger a resize event?

In your modern browsers, you can trigger the event using: window. dispatchEvent(new Event('resize'));

What does window resize do?

The resize event fires when the document view (window) has been resized. This event is not cancelable and does not bubble. In some earlier browsers it was possible to register resize event handlers on any HTML element.


1 Answers

Try to use this, its a pure javascript no JQuery involved.

window.resizeTo(width, height);
like image 63
ShankarSangoli Avatar answered Oct 23 '22 10:10

ShankarSangoli