Can jQuery change `$(window).width()`?

前端 未结 3 1971
南方客
南方客 2020-12-19 12:22

Is it possible to change $(window).width() via jQuery, so that something like this is possible:

$(\'#click\').click(function(){
   //menu 100px          


        
相关标签:
3条回答
  • 2020-12-19 12:48

    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.

    0 讨论(0)
  • 2020-12-19 12:51

    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

    0 讨论(0)
  • 2020-12-19 12:52

    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.

    0 讨论(0)
提交回复
热议问题