开发者

How can I remove scrollbars from an iframe using jquery?

开发者 https://www.devze.com 2023-01-09 02:06 出处:网络
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 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:

开发者_C百科
$('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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号