/    Sign up×
Community /Pin to ProfileBookmark

Start a new topic add your comments iframe dynamic width and height

Hi,

I would like to develop the iframe which contains the dynamic width and height and contains no scrollbars.

[QUOTE]

<script language=”JavaScript”>

function calcHeight(id)
{
//find the height of the internal page
var the_height=document.getElementById(id).contentWindow.document.body.scrollHeight;
document.getElementById(‘tframe’).height = (the_height) + “px”;

//find the Width of the internal page
var the_width=document.getElementById(id).contentWindow.document.documentElement.scrollWidth;
document.getElementById(‘the_width’).width = (the_width) + “px”;

}

</script>

<div id=”question”>
<iframe align=”center” title=”View” frameborder=”0″ id=”tframe” marginheight=”0″ marginwidth=”0″ name=”tframe” scrolling=”no” src=”sample.html” onload=”calcHeight(‘tframe’);”></iframe>
</div>

[/QUOTE]

The above coding working well in Firefox but in IE is not working.

The width property “document.documentElement.scrollWidth” is not supported in IE.

I tried by using document.body.scrollWidth , it is not supported both in IE as well as Firefox.

kindly help me to fix this issue

by
raveendran

to post a comment
JavaScript

0Be the first to comment 😎

×

Success!

Help @raveendran 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.28,
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,
)...