Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get rid of border for an Iframe in IE8

I am creating a dialog with an iframe inside, the problem is that the border keeps showing in IE8, this works perfectly in any other browser.

This is what I have tried, I also tried border:none

$(d.dialog).find('#MyCoolDialogInner').html('<iframe src="/apex/EscalationForm?id={!Case.Id}" height="495" width="380" marginheight="0" marginwidth="0" frameborder="0"/>'); 

Thanks in advance

like image 739
PepeFloyd Avatar asked Sep 13 '12 20:09

PepeFloyd


People also ask

How do you make an iframe border invisible?

Remove border from iframe tag in the webpage could be done by using one of the CSS properties of the iframe tag called frameBorder and set its value to “0”. Syntax: frameBorder = "value"; Note: In the frameBorder property the B letter must be in capital otherwise it will not be recognized by the browser.

How do I disable borders?

Go to Design > Page Borders. In the Borders and Shading box, on the Page Border tab, select the arrow next to Apply to and choose the page (or pages) you want to remove the border from. Under Setting, select None, and then select OK.

How do I disable a border in HTML?

We can set the border property to none to remove the border from an HTML table. The property is short-hand of different border properties. Those different properties are border-width , border-style and border-color . A border won't be formed when we use the border property and set it to none.

Does an iframe have a border around it?

The HTML Iframe frameborder Attribute is used to specify whether or not to display the border around the content of an <Iframe> Element. Attribute Values: 0: It has a Default value. It sets the border on one state.


4 Answers

Add the frameBorder attribute (note the capital ‘B’).

So it would look like:

<iframe frameBorder="0">Browser not compatible.</iframe>
like image 74
Anoop Avatar answered Oct 07 '22 17:10

Anoop


Have you tried setting it via CSS?

iframe {
    border:0px none transparent !important;
}

Also, these seem to work too - marginheight="0" marginwidth="0" frameborder="0". Taken from this post on the same IE issue.

like image 44
Robin Maben Avatar answered Oct 07 '22 15:10

Robin Maben


Try this:

<iframe frameborder="no" />
like image 32
Steven Hunt Avatar answered Oct 07 '22 16:10

Steven Hunt


I realize IE8 is a nuisance when it comes to iFRAMES. "Frameborder" is deprecated in HTML5 so while it's the easiest option for IE8, this is not a long term solution.

I have successfully hidden borders and scrollbars by placing the iFRAME inside of a container. The iFRAME container itself is placed inside of a div for overall positioning on the web page. The iFRAME itself is absolute positioned and negative margins applied to both top and left in order to hide the top and left borders. Width and height of the absolutely positioned iFRAME should be coded at over 100% so it exceeds the parent size to the point that the right and bottom borders are not visible (also the scrollbars are not visible). This technique also makes the iFrame responsive because the iFRAME container uses percentages as well as the div that holds the container. Of course the iFRAME parent div must be set to overflow:hidden.

Here is an example code:

    /*THE PARENT DIV FOR THE iFRAME CONTAINER*/
    .calcontainer
        {
        width:100%;  /*adjust iFrame shrinking here - if floating use percentage until no white space around image.*/   
        max-width:200px;     
        margin:auto;     
        }


    /*THE RELATIVE POSITIONED CONTAINER FOR THE iFRAME*/

    .calinside  /*container for iFRAME - contents will size huge if the container is not contained and sized*/
        {   
        position:relative; /*causes this to be the parent for the absolute iFRAME*/
        padding-bottom: 100%; /* This is the aspect ratio width to height ratio*/
        height: 0;
        overflow:hidden; /*hides the parts of the iFRAME that overflow due to negative margins and over 100% sizing*/     
        }


/*THE ABSOLUTE POSITIONED iFRAME contents WITH NEGATIVE MARGINS AND OVER 100% SIZE IS CODED HERE.  SEE THE NORMAL SETTINGS VERSUS THE IE8 SETTINGS AS MARKED.  A SEPARATE CSS FILE IS NEEDED FOR IE8 WITH A CONDITIONAL STATEMENT IN THE HEAD OF YOUR HTML DOCUMENT/WEB PAGE*/

    .calinside iframe
        {
        position: absolute;
        top: 0;
        left: 0;
        width: 100% !important;/*must expand to hide white space to the right and below.  Hidden overflow by parent above*/
        height: 103% !important; /*must expand to hide white space to the right and below.  Hidden overflow by parent above*/
        /*IE8*/top: -2%;
        /*IE8*/left: -2%;   
        /*IE8*/width: 114% !important;/*For IE8 hides right border and scroll bar area that is white*/  
        /*IE8*/height: 105% !important; /*hide white space and border below.  Hidden overflow by parent above*/          
        }
like image 45
Frugal Avatar answered Oct 07 '22 16:10

Frugal