2

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 windows

Adjust width height of iframe to fit with content in it

Community
  • 1
  • 1
Aximili
  • 28,626
  • 56
  • 157
  • 216

4 Answers4

2

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
});
alex
  • 479,566
  • 201
  • 878
  • 984
  • This is good, I can then use window.resizeBy() But it doesn't work in IE :( Do you know a workaround for IE? – Aximili Jun 11 '09 at 05:08
1

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.

Avitus
  • 15,640
  • 6
  • 43
  • 53
1

Solved

$(document).ready(function() {

  // For IE
  var 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());
  });
});
Aximili
  • 28,626
  • 56
  • 157
  • 216
0

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

jrista
  • 32,447
  • 15
  • 90
  • 130