SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Addict
    Join Date
    Dec 2007
    Posts
    207
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Modal Window With Dynamic Width

    I have a modal window and want it's width to be set according to how wide the content within it is. The content is set dynamically and the modal window is centered. This should be pretty simple but I can't figure out how to do this.

  2. #2
    Beer Monster -Ox's Avatar
    Join Date
    Apr 2003
    Location
    sowth afreeka
    Posts
    374
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Not tested but you'd have to put something like this in the <head> tag to resize the window once it's loaded.

    Code:
    <script type="text/javascript">
        window.onload = function () {
            // Find out the width of the element that you're wanting to resize the windows to, however you want to do it, this is mearly a suggestion
            var width = document.getElementById('content_div').offsetWidth;
            // Then resize that window
            window.resizeTo(width);
        }
    </script>
    Please note, I have not tested this, and not sure if it will work with a dialog window, I know it works with a normal winow.open

    -Ox
    My postings are a natural product.
    The slight variations in spelling and grammar enhance its
    individual character and beauty and in no way are to be
    considered flaws or defects - http://www.guinnesspig.net


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •