/    Sign up×
Community /Pin to ProfileBookmark

Dynamic height of window

Hi,

I’m new to JavaScript but not to programming ?
What I’m doing is a little system where clients have little pop-up window open on their PC which displays information.

That window retreives textual information from a database once a minute. So the information in the window is dynamic and it automatically updates itself.

What I’m thinking about is letting this window (which has no toolbar, statusbar etc.) have fixed width but dynamic height depending on the information needed to be displayed.

So instead of having scrollbars and having the user scroll up/down I want the window to display all information each time…so if information is added to the database…next time the window retrieves this information it gets higher). In other words, no interaction from the user.

Is this possible, the application is otherwise written in PHP….hope you understand what I mean!!

to post a comment
JavaScript

3 Comments(s)

Copy linkTweet thisAlerts:
@GollumDec 05.2003 — Sure you can!

what you need to do is first put a <div> around all of your content...
<i>
</i>&lt;body onload="setHeight();"&gt;
&lt;div id=surround style="width:300"&gt;
... all your data goes here
&lt;/div&gt;
&lt;/body&gt;


the onload in your body tag calls the function setHeight()...
<i>
</i>function setHeight()
{
// calculate current client area
var ch;
if ( document.body.clientHeight )
{
ch = document.body.clientHeight;
}
else if ( window.innerHeight )
{
ch = window.innerHeight;
}
else
{
return;
}

var margin = 30;

var y;
var oSurround = document.getElementById('surround');
if ( oSurround.offsetHeight )
{
y = oSurround.offsetHeight;
}
else if ( oSurround.naturalHeight )
{
y = oSurround.naturalHeight;
}
else
{
return;
}

top.window.resizeBy(0,y+margin-ch);
top.window.focus();
}
Copy linkTweet thisAlerts:
@darcsinxauthorDec 05.2003 — Thank you, that certainly got me going and this works fine to some extent. Firstly, I have to move the window after I resize it so it always stays in the bottom left corner...not very hard and I'll figure that out myself (using moveTo)

The other problem is that I have to try to get it to work in Netscape 4.79...yes that's Netscape 4 :mad:

Any suggestions about how to accomplish that, or if it is even possible !!?!
Copy linkTweet thisAlerts:
@darcsinxauthorDec 09.2003 — Anyone, I'm having some trouble getting this to work in Netscape 4, i.e. getting the size between <div> tags

And, yes, I'm lazy ?
×

Success!

Help @darcsinx spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.27,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...