/    Sign up×
Community /Pin to ProfileBookmark

Javascript Iframe Detect Help

I recently found a need to have a Javascript auto detect the page height, and width of my iframe i was using on my website.

[CODE]<script>
document.write(‘<iframe width=”‘+(window.innerWidth?window.innerWidth:document.body.clientWidth)+'” height=”‘+(window.innerHeight?window.innerHeight:document.body.clientHeight)+'” src=”report.cfm” name=”content”></iframe>’);
</script>[/CODE]

Is the code I am using, and it works extremely well, however the problem is not only do i need the script to auto-detect the page height, and width, but i need it to only do so to fill up the remaing space, NOT taken up by the navagation at the top. ie, if the Page Display is 1024×768 then i need the iframe to be 900×768

Anyone see where I can improve my code to not only auto detect the window size, but also factor in that it needs to be 124 pixels smaller than the max window height?

full code is here

[CODE]<DIV id=content style=”Z-INDEX: 1; LEFT: 0px; RIGHT: 0px; WIDTH: 1013px; POSITION: absolute; TOP: 69px; HEIGHT: 546px”>

<script>
document.write(‘<iframe width=”‘+(window.innerWidth?window.innerWidth:document.body.clientWidth)+'” height=”‘+(window.innerHeight?window.innerHeight:document.body.clientHeight)+'” src=”report.cfm” name=”content”></iframe>’);
</script>

<!—
<IFRAME src=”report.cfm” frameBorder=0 width=100% height=100% name=”content”>
—>
</DIV>[/CODE]

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@felgallApr 03.2006 — &lt;script type="text/javascript"&gt;
document.write('&lt;iframe width="'+[b]([/b](window.innerWidth?window.innerWidth:document.body.clientWidth)[b] - 124)[/b] +'" height="'+(window.innerHeight?window.innerHeight:document.body.clientHeight)+'" src="report.cfm" name="content"&gt;&lt;/iframe&gt;');
&lt;/script&gt;
Copy linkTweet thisAlerts:
@skilled1authorApr 03.2006 — bah so simple, i do not know how i missed it, thank you very much sir
×

Success!

Help @skilled1 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 6.18,
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: @nearjob,
tipped: article
amount: 1000 SATS,

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

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...