简体   繁体   中英

How can I remove scrollbars from an iframe using jquery?

I have a page that I don't control the source to. It contains an iframe. The iframe has scrollbars and a border. I want to remove both. I tried using Jquery like this:

$('iframe').attr('scrolling', 'no');

Nothing I do will affect the iframes attributes at all.

Any ideas? (IE8)

http://www.w3.org/TR/html4/present/frames.html#h-16.5

<iframe scrolling="no" frameborder="0">

You can access the iframe's attributes using jQuery , and simply set the scrolling to "no" like this:

$("#frame")[0].setAttribute("scrolling", "no");

Just be sure to append the [0] as above, so the jQuery object will return the first DOM element.

frameborder="0" I believe for the border part. You could play around with css overflow for the scrolling, not exactly sure about that.

Try this.

$("iframe").each(
     function(index, elem) {
         elem.setAttribute("scrolling","no");
     }
 );

I didn't test it but it should work.

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