Resize popup window to fit text

T

Terren

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
 
T

Terren

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>
 
E

Evertjan.

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.
 
E

Evertjan.

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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,567
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top