• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

Quick help needed w/ Resizing web window in javascript

dmurray14

Golden Member
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
 
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
 
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?
 
if you have this: <iframe id="pdf"></iframe>

Use javascript like this:

document.getElementById("pdf").style.height = (document.body.clientHeight - 40) + "px";
 
Why won't the document.write method work? document.write("<embed height=" + (document.body.clientHeight - 40) & " />")
 
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?
 
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
 
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.
 
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
 
Back
Top