Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. JavaScript
  4. jquery dialog autosize [modified]

jquery dialog autosize [modified]

Scheduled Pinned Locked Moved JavaScript
javascript
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • F Offline
    F Offline
    fififlowertot
    wrote on last edited by
    #1

    Hi, I have a jquery dialog which loads another aspx page inside iframe. I want dialog to resize as per the contents inside Iframe. Tried setting

    width:'auto' and autoResize: true

    in the dialog constructor but no luck.

    modified on Wednesday, August 24, 2011 9:25 AM

    G 1 Reply Last reply
    0
    • F fififlowertot

      Hi, I have a jquery dialog which loads another aspx page inside iframe. I want dialog to resize as per the contents inside Iframe. Tried setting

      width:'auto' and autoResize: true

      in the dialog constructor but no luck.

      modified on Wednesday, August 24, 2011 9:25 AM

      G Offline
      G Offline
      Gerben Jongerius
      wrote on last edited by
      #2

      You will have to create some javascript yourself to build this. First you will have to attach an event to the onload of the iframe. In that onload function you will have to try to calculate the height of the contents and resize the jQuery dialog window. I built something similar a couple of months back, but it didn't work equally well in all scenario's.

      // title, url, name, ok_title, width, height <-- these were input variables for my code
      var popup_div = document.createElement('div');
      var popup_content = document.createElement('iframe');
      var dialog = null;
      jQuery(popup_content).css({ 'width': '100%', 'height': '100%', 'border': 'none', 'visibility': 'hidden' });
      popup_content.src = url;
      popup_content.name = name;
      popup_div.id = 'bb-dialog';
      popup_div.appendChild(popup_content);
      document.body.appendChild(popup_div);

        jQuery(popup\_content).bind('load', function () {
          height = height == 'auto' ? jQuery(top.window.frames\[name\]).height() : height,
          width = width == 'auto' ? jQuery(top.window.frames\[name\]).width() : width;
      
          jQuery(popup\_div).dialog({
            show: 'fade',
            hide: 'fade',
            title: title,
            modal: true,
            position: 'center',
            width: width,
            height: height,
            closeOnEscape: false,
            close: function () { this.parentNode.parentNode.removeChild(this.parentNode); },
            open: function () { jQuery(popup\_content).css('visibility', 'visible'); },
            buttons: button\_set
          });
      
          jQuery(this).unbind('load');
        });
      

      Try it out and see if it works for you. Though you might have to tweak it a little bit.

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups