Can jQuery change `$(window).width()`?
Is it possible to change $(window).width()
via jQuery, so that something like this is possible:
$('#click').click(function(){
//menu开发者_JS百科 100px with $(window).width();
});
No it's not. The underlying DOM element itself doesn't support modifying the width of the browser window. It is possible to change the dimensions of the content (outerWidth / innerWidth) area. However I don't believe this has an affect on the size of the window which is what you seem to want to achieve
You can control the size of a new browser window that you open with window.open()
. See https://developer.mozilla.org/En/Window.open for how to do that.
I'm not sure about other browsers (tried it in Chrome and it didn't work), however FireFox will allow you to resize the window using:
window.resizeTo(1280,1024);
I have a bookmark with
javascript:window.resizeTo(1280,1024);
To resize the window to see what sites I develop look like at different resolutions.
精彩评论