简体   繁体   中英

Scrolling attribute doesn't work for iframe

Example: jsfiddle

html:

<iframe id="frame" scrolling="no"></iframe>

js:

frame.contentWindow.document.write('scroll</br><div style="width:100px;height:100px;"><canvas id="cv"></canvas></div>');
var cv = frame.contentWindow.document.body.childNodes[2].childNodes[0];
var context = cv.getContext("2d");
cv.height = cv.width = 500;
context.fillStyle = "red";
context.rect(0, 0, 500, 500);
context.fill();

Why doesn't this work on android 4.2 (maybe in others)? Why i can scroll an iframe when scrolling="no"? Without canvas all works perfectly.

Be aware that the scrolling="no" attribute for iFrame was removed from HTML5. That said, the only real and trustable way to avoid scrolling in iFrame is building a content large, at the most, as the iFrame itself.

My experience says that, even if checking result on as many browsers as possible, it would be always a configuration that shows scrollbars anyway....

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM