bsm bsm - 6 months ago 9
HTML Question

How to add scrollbars in iframe

I want to add scrollbars in my iframe. Below is my code.

<iframe src="http://www.w3schools.com" width="1349px" height="100%" scrolling="auto">

</iframe>


I am writing this in Drupal 7. Problem is it doesn't show iframe with scrollbars and border. Earlier I simply set the source without width and height and scrolling options and it showed iframe with scrollbars but after adding width and height,it disappeared.

Thanks

Answer

scrolling="yes" and also frameborder aren't valid HTML5 attributes anymore. They can't be found in the list of allowed attributes, see: W3C: 4.7.6. The iframe element or MDN: <iframe>.

Use CSS instead:

iframe {
    overflow: scroll;
    width: 1349px;
    height: 100%;
    border: 1px solid black;
}

But actually all browsers show the scrollbars right away if needed.

Demo

Try before buy

Comments