You are here: Reference > JavaScript > client-side > HTML DOM > properties > scrolling (frame, iframe)
scrolling property (frame, iframe)
Sets or retrieves whether a frame has scrollbars.
If you want to change one of the element's scrollbar state, use the overflow style property, or if you want to change the scrollbar state of the entire page (Internet Explorer), use the scroll property.
Syntax:
You can find the related objects in the Supported by objects section below.
This property is read/write.
HTML page for this property: scrolling |
Possible values:
String that sets or retrieves the state of scrollbars.
One of the following values:
Default. Scrollbars are added only when necessary. | |||||||
Scrollbars are not added. | |||||||
Scrollbars are always added.
This value behaves differently in browsers:
|
Default: auto.
Example HTML code 1:
This example illustrates the use of the scrolling attribute. Note that the value of 'yes' behaves differently in browsers (see above). If you want that scrollbars will be always added to a frame, use the overflow style property. The next example demonstrates it.
|
|||||||
<head> <style> iframe { width:200px; height:150px; } </style> </head> <body> <iframe src="frameScroll1.htm" scrolling="yes"></iframe> <iframe src="frameNoScroll1.htm" scrolling="no"></iframe> </body> |
|||||||
|
|||||||
Did you find this example helpful?
|
Example HTML code 2:
This example shows how to add scrollbars to a frame in all commonly used browsers. It uses the overflow style property of the html element to implement it.
|
|||||||
<head> <style> iframe { width:200px; height:150px; } </style> </head> <body> <iframe src="frameScroll2.htm"></iframe> <iframe src="frameNoScroll2.htm"></iframe> </body> |
|||||||
|
|||||||
Did you find this example helpful?
|
Example HTML code 3:
This example illustrates the use of the scrolling property. Although the value of the scrolling property can be modified in JavaScript, it has no any visual effect in Internet Explorer, Google Chrome and Safari. See the next example, it shows a cross-browser solution.
|
|||||
<head> <style> iframe { width:200px; height:150px; } </style> <script type="text/javascript"> function ChangeScrollState (select) { var iframe = document.getElementById ("myIFrame"); iframe.scrolling = select.value; } </script> </head> <body> <iframe id="myIFrame" src="frameOverflow.htm" /></iframe> <select onchange="ChangeScrollState (this);" size="3"> <option value="auto" selected="selected" />auto <option value="no" />no <option value="yes" />yes </select> </body> |
|||||
|
|||||
Did you find this example helpful?
|
Example HTML code 4:
This example shows how to change the state of an iframe's scrollbars at runtime.
|
|||||
<head> <style> iframe { width:200px; height:150px; } </style> <script type="text/javascript"> function ChangeScrollState (select) { var iframe = document.getElementById ("myIFrame"); var frameDoc = iframe.contentWindow.document; frameDoc.documentElement.style.overflow = select.value; } </script> </head> <body> <iframe id="myIFrame" src="frameOverflow.htm" /></iframe> <select onchange="ChangeScrollState (this);" size="3"> <option value="auto" selected="selected" />auto <option value="scroll" />show <option value="hidden" />hide </select> </body> |
|||||
|
|||||
Did you find this example helpful?
|
Supported by objects:
Related pages:
External links:
User Contributed Comments