treehouse : what would you like to learn today?
Web Design Web Development iOS Development

Scrolling, Frameborder, and Allowtransparency Attributes in IE.

  • I am working on a website here. I am using iframes for the navbar and footer. Because of IE 8 and older I must set the following attributes on the iframes: allowtransparency="true", frameborder="0", and scrolling="no". None of these will validate, so therefore I am using JavaScript to set these attributes using the following code:

    onload = function()
    {
    var theframes = document.getElementsByTagName( 'iframe' );
    for( var i = 0; i < theframes.length; i++ )
    {
    theframes[i].setAttribute( "frameborder", "0" );
    }
    for( var i = 0; i < theframes.length; i++ )
    {
    theframes[i].setAttribute( "allowTransparency", "true" );
    }
    for( var i = 0; i < theframes.length; i++ )
    {
    theframes[i].setAttribute( "scrolling", "no" );
    }
    }

    I have also tried this:

    onload = function()
    {
    var theframes = document.getElementsByTagName( 'iframe' );
    for( var i = 0; i < theframes.length; i++ )
    {
    theframes[i].setAttribute( "frameborder", "0" );
    theframes[i].setAttribute( "allowTransparency", "true" );
    theframes[i].setAttribute( "scrolling", "no" );
    }
    }

    Both of these only the allowtransparency works. I am still a novice to Javascript and any help would be appreciated.
    The page using this code can be found here. (Note that this is the 404 error page.)
    -Cliff
  • it could be iframe browser security issue, you cannot set some attributes via javascript on iframes.
  • Hmmm... interesting. Do you know which attributes are not settable via javascript, and why?
    Thanks,
    Cliff