Reputation: 22847
My page is loaded into iframe, and I need to adapt the size of that iframe using javascript. I try the following:
iframe.style.overflow = 'hidden'
iframe.scrolling = 'no'
var content = iframe.contentWindow.document.getElementById('content')
var height = content.offsetHeight + 10
iframe.style.height = height + 'px'
console.log(content.offsetWidth)
var width = content.offsetWidth + 10
iframe.style.width = width + 'px'
On FireFox it works as supposed to, but IE9 ignores both scrolling and overflow attributes. The browser mode is set to IE9-Standards.
How to get rid of that scroll in iframe under IE9?
Upvotes: 0
Views: 720
Reputation: 23406
Looks like the iframe
is loaded, when you're doing this. You can set:
iframe.contentWindow.document.body.style.overflow = 'hidden';
If there's a literal iframe
tag on the page, you can set scrolling
attribute to "no"
, but when setting this attribute value with JS after iframe
element has been created to a page, doesn't work. If you're creating the iframe
dynamically, you can set setAttribute('scrolling', 'no')
before appending it into a document.
Upvotes: 1