Adapt size of popup to its content's size?

D

Daniel Fugmann

Hello,

I use popups to show small pieces of information. These texts vary
much in their lenghts and I dislike fixed size popups here because
when the text is short there is so much empty space.

Any possibilities to automatically resize a popup according to its
content? (I. e. no scrollbars, no big empty areas)

Thanx !!!

Daniel
 
K

kaeli

I use popups to show small pieces of information. These texts vary
much in their lenghts and I dislike fixed size popups here because
when the text is short there is so much empty space.

Any possibilities to automatically resize a popup according to its
content? (I. e. no scrollbars, no big empty areas)

I have yet to find a good cross-browser way of doing this. Plus, many
browsers these days allow users to turn off resizing.
Do you have a target browser? IIRC, I got it to work with IE or with
Netscape, but not both at the same time. :)

--
--
~kaeli~
If a chicken and a half can lay an egg and a half in a day
and a half, how long would it take for a monkey with a
wooden leg to kick the dill seeds out of a pickle?
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace
 
T

Thomas 'PointedEars' Lahn

Daniel said:
Any possibilities to automatically resize a popup according to its
content? (I. e. no scrollbars, no big empty areas)

Mozilla/5.0 know sizeToContent(), but they also allow for tabbed browsing
and provide preferences for disabling resize, so calling that method on an
Internet Web site may be not so good an idea.

IE 4+ has document.body.offset*, but Active Scripting may be disabled or
the parent application or an extension/PFW may allow restriction of the
IE browser component like Mozilla/5.0 does.

I don't know about Opera and the other thousands of UAs out there ...

Don't do it. Users are smart enough to resize the window themselves.
If you have a maximum window size, like with an image gallery, you may
use these values then or rescale all your images to fit a fixed minimum
size.


PointedEars
 
D

Daniel Fugmann

I got it to work with IE or with
Netscape, but not both at the same time. :)

--

I'm curios about your solution ? (For each of the browsers you've done
it for. My target browser actually is "every browser" since it is a
public site. I. e. I'd like to realize it for as many browsers
possible. At least, want to test it for a while.) Thx!

D.
 
K

kaeli

I'm curios about your solution ? (For each of the browsers you've done
it for. My target browser actually is "every browser" since it is a
public site. I. e. I'd like to realize it for as many browsers
possible. At least, want to test it for a while.) Thx!

D.

Pretty much took this and flew with it.

From: http://www.howtocreate.co.uk/perfectPopups.html

function resizeWinTo( idOfDiv ) {
var oH = getRefToDivMod( idOfDiv ); if( !oH ) { return false; }
var oW = oH.clip ? oH.clip.width : oH.offsetWidth;
var oH = oH.clip ? oH.clip.height : oH.offsetHeight; if( !oH ) { return
false; }
var x = window; x.resizeTo( oW + 200, oH + 200 );
var myW = 0, myH = 0, d = x.document.documentElement, b =
x.document.body;
if( x.innerWidth ) { myW = x.innerWidth; myH = x.innerHeight; }
else if( d && d.clientWidth ) { myW = d.clientWidth; myH =
d.clientHeight; }
else if( b && b.clientWidth ) { myW = b.clientWidth; myH =
b.clientHeight; }
if( window.opera && !document.childNodes ) { myW += 16; }
x.resizeTo( oW + ( ( oW + 200 ) - myW ), oH + ( (oH + 200 ) - myH ) );
}

Trying to make that work when NOT using a div, as the author does, was
proving difficult because I couldn't seem to get the right height in BOTH
browser.
Here's what I posted last time about the height issue. Width didn't give me
nearly as hard a time. *LOL*
<URL: http://groups.google.com/groups?hl=en&lr=&ie=UTF-8
&selm=MPG.1b60b117bb991f1989f9c%40nntp.lucent.com >

I suppose you could do checks for 0 values and whatnot to get it to at least
work in both NN and IE.

--
 

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

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top