Quick help needed w/ Resizing web window in javascript

dmurray14

Golden Member
Feb 21, 2003
1,780
0
0
Here's what I'm doing...I have a web PDF viewer that I made for a web site...it loads up a pdf from a URL string and embeds it in the page. At the top of the page is a navigation bar in a table that is 40px tall that has various options that have to do with the website. Everything works fine, the PDF embeds fine below the navigation bar, with one exception - I have the width set to 100%, but obviously I can't set the height to 100%. I can't set a static height, as broswer windows come in different sizes, so I need to be able to have the embedded pdf strech to fill the screen. The only way I can think to do this is using javascript.

So, what I'd like to do is get the screen height, subtract 40 from it (for the nav bar) and then have that value become the height of the screen. I know I can get the screen height using document.body.clientHeight, but from there I'm lost. Should I do a document.write with the html in the middle? How do I subtract 40 from the screen height? I don't know...

Thanks,
Dan
 

dmurray14

Golden Member
Feb 21, 2003
1,780
0
0
Originally posted by: So
Can't CSS do this?

How would CSS do it?

I'm really just interested in getting this done, and I know for sure javascript can do it, just don't know a) how to get it to subtract 40 from the screen height (document.body.clientHeight) and how to stick that value in the height portion of the embed tag...

Dan
 

dmurray14

Golden Member
Feb 21, 2003
1,780
0
0
OK go figure, I tried using an IFRAME, but no matter what I enter for the percentage, it stays at about 110% of the page...any ideas?
 

notfred

Lifer
Feb 12, 2001
38,241
4
0
if you have this: <iframe id="pdf"></iframe>

Use javascript like this:

document.getElementById("pdf").style.height = (document.body.clientHeight - 40) + "px";
 

KB

Diamond Member
Nov 8, 1999
5,396
383
126
Why won't the document.write method work? document.write("<embed height=" + (document.body.clientHeight - 40) & " />")
 

dmurray14

Golden Member
Feb 21, 2003
1,780
0
0
Originally posted by: notfred
if you have this: <iframe id="pdf"></iframe>

Use javascript like this:

document.getElementById("pdf").style.height = (document.body.clientHeight - 40) + "px";

Thanks, but that didn't work - it's going after the iframe right?
 

dmurray14

Golden Member
Feb 21, 2003
1,780
0
0
Originally posted by: KB
Why won't the document.write method work? document.write("<embed height=" + (document.body.clientHeight - 40) & " />")

I guess that could work, but don't I need to have quotes around what the height =?

for instance, you would write height="45" with the quotes. How would I put them in in javascript?

Dan
 

dmurray14

Golden Member
Feb 21, 2003
1,780
0
0
Originally posted by: Mo0o
Originally posted by: dmurray14
Originally posted by: troytime
whoa, nik hasn't posted in this topic yet

if nik can answer my question, get him...;)

He'll post, but he definitely wont answer your question


thats cute...


anyone have any ideas? I need this done within the next hour...

Dan
 

So

Lifer
Jul 2, 2001
25,921
14
81
Originally posted by: dmurray14
Originally posted by: Mo0o
Originally posted by: dmurray14
Originally posted by: troytime
whoa, nik hasn't posted in this topic yet

if nik can answer my question, get him...;)

He'll post, but he definitely wont answer your question


thats cute...


anyone have any ideas? I need this done within the next hour...

Dan

IIRC, in CSS, heights can be set as percentages.
 

dmurray14

Golden Member
Feb 21, 2003
1,780
0
0
Yeah, but I'm having trouble with that - it's just not working on my iframe, probably due to the way the PDF is embedding. I feel like I am so close with the javascript solution...

Dan