Setting minimum size for JavaScript popup

Is there a way to set the minimum size of the popup via JavaScript?

My problem is that when someone makes it as small as they can, the content just looks stupid.

+1


a source to share


5 answers


Most browsers have minimum width and height.



Internet Explorer 7 minimum width> 250 pixels minimum height> 150px

0


a source


When creating popups, you can only set width and height. But since the popup was created, this means that you can change the height and width of the window when the popups are loaded. Just place the onload event inside the popup:

window.onload = function() {
  if (document.body.scrollHeight) {
     var winWidth = document.body.scrollWidth;
     var winHeight = document.body.scrollHeight;
  } else if (document.documentElement.scrollHeight) {
     var winHeight = document.documentElement.scrollHeight;
     var winWidth = document.documentElement.scrollWidth;
  } else {
     var winHeight = document.documentElement.offsetHeight;
     var winWidth = document.documentElement.offsetWidth;
  }
  window.resizeTo(winWidth, winHeight);
}

      



edit: Tested in IE7.8, Chrome, Safari 4, Firefox 3. Works, but you may need to consider menu size + address bars and such as the window size will be the outer size and this function will find the size of the content. So to be on the safe side, you should probably add a couple of pixels and also disable scrollbars in the popup to make sure they don't take up space.

+3


a source


I don't believe you can set the minimum using a new Javascript window. I know you can set the size and disable scrollbars and prevent resizing, but that will answer the minimum, but also impose the maximum, which you might not want.

+1


a source


When using windows.open, you can specify the height and width of the window as follows:

window.open (" http://www.stackoverflow.com ", "MyWindow", "MenuBar = 1, resizable = 1, width = 350, height = 250 ");

However, this is not the minimum size, as the window will no longer be larger when there is more space. To do this, you will need to check the screen space.

0


a source


http://www.htmlgoodies.com/beyond/javascript/article.php/3471221

As you can see from the link, you can set the minimum size. If you want to scale it to be larger, you must do so from the popup.

0


a source







All Articles