Quote:
Originally Posted by MichaelHGoebel
I have an iFrame on which I wish to display scrollbars ONLY when the mouse is over the iFrame AND the source of the iFrame is larger than the iFrame can display
|
IE doesn't seem to style overflow for iframes; perhaps for security reasons.
This works for same-domain iframes. Don't style overflow:hidden using CSS.
Code:
<iframe id='myIframe' src='iframesource.htm' ></iframe>
<script type='text/javascript'>
(function( id )
{
function noBars( elem, action )
{
try
{
elem.contentWindow.document.body.style.overflow = ( action ? 'hidden' : 'auto' );
}
catch( e ){}
}
var ifr = document.getElementById( id );
ifr.onload = function(){ noBars( ifr, true ); };
ifr.onmouseover = function(){ noBars( ifr, false ); }
ifr.onmouseout = function(){ noBars( ifr, true ); }
})( "myIframe" );
</script>