Resize popup window to fit text

Discussion in 'ASP General' started by Terren, Sep 28, 2005.

  1. Terren

    Terren Guest

    I have a popup window that is used to display text from a database.
    Some times it can be a few words, sometimes it can be a hundred words.

    What I would like to do is resize the popup window to fit the text.
    Well actually it is just the height that needs to be resized. I have
    set the width to 600. I have put the text in a table and I was thinking
    I could set the height of the window to be the height of the table plus
    some for room. I don't know if that is possible.

    At first I tried to count the number of lines and multiple by a factor
    by that doesn't work so nicely because I was getting the number of
    lines by dividing the number of charaters by the maximum number of
    characters in a line.

    Let me know if I am just being stupid and I should abondon this quest
    Terren, Sep 28, 2005
    #1
    1. Advertising

  2. Terren

    Terren Guest

    What? No one replied? Well here is the solution. Turns out it is really
    easy, maybe that is why no one replied.

    Here is the script function to do this.

    <script type="text/javascript">
    function ChangeHeight(window_width){
    var mtop,mleft
    if (screen.height>
    document.getElementById("table_id").offsetHeight){
    //resize window
    window.resizeTo(window_width,document.getElementById("table_id").offsetHeight+75);
    // The +75 is because the title bar takes up some space. I am sure that
    this will be different for different resolutions
    //Center Window
    mtop=(screen.height/2)-(window.length/2);
    mleft=(screen.width/2)- (window_width/2);
    window.moveTo(mleft,mtop);
    }else{
    //resize window
    window.resizeTo(window_width,screen.height-75);
    //Center Window
    mtop=(screen.height/2)-((screen.height)/2);
    mleft=(screen.width/2)-(window_width/2);
    window.moveTo(mleft,mtop);
    }//end if
    }//end function
    </script>
    Terren, Sep 29, 2005
    #2
    1. Advertising

  3. Terren

    Evertjan. Guest

    Terren wrote on 29 sep 2005 in microsoft.public.inetserver.asp.general:
    > What? No one replied? Well here is the solution. Turns out it is really
    > easy, maybe that is why no one replied.



    No one replied,
    because you are asking a clientside Q in a serverside scripting NG,
    and so you were off topic.

    Choose your NG carefully according to your Q.

    --
    Evertjan.
    The Netherlands.
    (Replace all crosses with dots in my emailaddress)
    Evertjan., Sep 29, 2005
    #3
  4. Terren

    Terren Guest

    Good point
    Terren, Sep 29, 2005
    #4
  5. Terren

    Evertjan. Guest

    Terren wrote on 29 sep 2005 in microsoft.public.inetserver.asp.general:
    > Good point


    Could be,
    but if you don't quote what you are anwering on,
    as per Netiquette,
    how are we to know what you are talking about?

    This is not email, but usenet.


    --
    Evertjan.
    The Netherlands.
    (Replace all crosses with dots in my emailaddress)
    Evertjan., Sep 29, 2005
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Piet
    Replies:
    0
    Views:
    503
  2. Steve C. Orr [MCSD, MVP, CSM, ASP Insider]

    Re: Resize Page Header to fit screen

    Steve C. Orr [MCSD, MVP, CSM, ASP Insider], Jan 22, 2007, in forum: ASP .Net
    Replies:
    0
    Views:
    639
    Steve C. Orr [MCSD, MVP, CSM, ASP Insider]
    Jan 22, 2007
  3. zorro
    Replies:
    9
    Views:
    686
    Neredbojias
    Jul 6, 2007
  4. Jens Peter Hansen
    Replies:
    7
    Views:
    498
    Randy Webb
    Jun 19, 2004
  5. Raffi
    Replies:
    4
    Views:
    201
    Dr John Stockton
    Aug 12, 2004
Loading...

Share This Page