PDA

View Full Version : iframe scrolling property does not work


soumik
09-15-2005, 04:55 AM
hi to all,

i hav one inline frame. the scrolling property of the iframe is "no" by default. what i want for a specific page it turns into "yes". so what i'm doing is targeting the iframe by id and changing the scrolling properties of it.. .. but it does not seem to be working properly. here is the code

<script language="JavaScript" type="text/JavaScript">
function scroll() {
parent.document.getElementById("iframe").scrolling='yes';
}
</script>

iframe id=mid
width=100%
height=100%

i'm calling the function on body load of a html which is going to load inside the iframe, thts why i had started with .parent so that it goes one up level, since the main iframe(mid) is located in the up level page.

i dont hav any problem when i apply the same code with the "width" property of the iframe, where the code is

function scroll() {
parent.document.getElementById("mid").width=400;
}

however, i want the code to modify the scrolling properties, not the widh....

if anyone has got any idea about the problem, i'm begging for it.. i need that to happen very badly...

thanx in advance..

soumik

coothead
09-15-2005, 07:36 AM
Hi there soumik,

and a warm welcome to these forums. :)
Unfortunately, Firefox appears to be the only browser that accepts...
document.getElementById("iframe").scrolling='yes'

You may be interested in this, if somewhat inelegant, work-a-round...
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/1999/REC-html401-19991224">
<html>
<head>
<title>create iframe scrolling</title>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<script type="text/javascript">
<!--
function scroll() {
parent.document.getElementById("foo").innerHTML=
'<iframe id="iframe" src="http://www.google.com/" width="400" height="500" scrolling="auto"><\/iframe>'
}
//-->
</script>

</head>
<body>

<div onclick="scroll()">click here for iframe scrolling</div>

<div id="foo">
<iframe id="iframe" src="http://www.google.com/" width="400" height="500" scrolling="no"></iframe>
</div>

</body>
</html>

soumik
09-20-2005, 01:40 AM
thank you very very much coothead. that solves my problem.

_Aerospace_Eng_
09-20-2005, 02:30 AM
Why even use javascript for this? Why not just use scrolling="auto" if the page being iframed needs scrollbars it will acquire them. If it doesn't need them it will act the same way as scrolling="no"