Skip to content Skip to sidebar Skip to footer

Dynamic Height For Popups Depending On Content, Is It Possible?

Is it possible to get a window popup with always 400px wide, but dynamic height depending on the content in the popup window? I have seen this but not sure how to apply it to popup

Solution 1:

Well, since you're relying on JavaScript to popup, you could do this... You've tagged jQuery, so here is a start... Place this in the popup.

$(document).ready(function() {

var popupHeight = parseInt($('#elementThatWillGetTaller').css('height')); // parseInt if we get a '200px'// code to set window height - I know it can be done because I've seen osCommerce do it
});

Solution 2:

The quickest solution would be to know the height of the window prior to opening it. If you know that then you can pass that as a parameter to the function that opens the popup window thus making the popup the correct height.

Solution 3:

Solved

$(document).ready(function() {

  // For IEvar h = $('#page').outerHeight();
  var newH = h + 20;
  window.resizeBy(0, newH - $(window).height());

  // Only works in Firefox/Safari
  $('img').load(function() {
    var h = $('#page').outerHeight();
    var newH = h + 20;
    window.resizeBy(0, newH - $(window).height());
  });
});

Solution 4:

If you specify overflow: auto and do not specify a height on an element, that element should grow in height dynamically.

Post a Comment for "Dynamic Height For Popups Depending On Content, Is It Possible?"