Annotation of html5/spec/the-iframe-element.html, revision 1.148

1.61      mike        1: <!DOCTYPE html>
1.146     mike        2: <html lang="en-US-x-Hixie"><head><title>4.8.2 The iframe element &#8212; HTML5</title><style type="text/css">
1.1       mike        3:    pre { margin-left: 2em; white-space: pre-wrap; }
                      4:    h2 { margin: 3em 0 1em 0; }
                      5:    h3 { margin: 2.5em 0 1em 0; }
                      6:    h4 { margin: 2.5em 0 0.75em 0; }
                      7:    h5, h6 { margin: 2.5em 0 1em; }
                      8:    h1 + h2, h1 + h2 + h2 { margin: 0.75em 0 0.75em; }
                      9:    h2 + h3, h3 + h4, h4 + h5, h5 + h6 { margin-top: 0.5em; }
                     10:    p { margin: 1em 0; }
                     11:    hr:not(.top) { display: block; background: none; border: none; padding: 0; margin: 2em 0; height: auto; }
                     12:    dl, dd { margin-top: 0; margin-bottom: 0; }
                     13:    dt { margin-top: 0.75em; margin-bottom: 0.25em; clear: left; }
                     14:    dt + dt { margin-top: 0; }
                     15:    dd dt { margin-top: 0.25em; margin-bottom: 0; }
                     16:    dd p { margin-top: 0; }
                     17:    dd dl + p { margin-top: 1em; }
                     18:    dd table + p { margin-top: 1em; }
                     19:    p + * > li, dd li { margin: 1em 0; }
                     20:    dt, dfn { font-weight: bold; font-style: normal; }
1.83      mike       21:    i, em { font-style: italic; }
1.1       mike       22:    dt dfn { font-style: italic; }
                     23:    pre, code { font-size: inherit; font-family: monospace; font-variant: normal; }
                     24:    pre strong { color: black; font: inherit; font-weight: bold; background: yellow; }
                     25:    pre em { font-weight: bolder; font-style: normal; }
                     26:    @media screen { code { color: orangered; } code :link, code :visited { color: inherit; } }
                     27:    var sub { vertical-align: bottom; font-size: smaller; position: relative; top: 0.1em; }
                     28:    table { border-collapse: collapse; border-style: hidden hidden none hidden; }
                     29:    table thead, table tbody { border-bottom: solid; }
                     30:    table tbody th:first-child { border-left: solid; }
                     31:    table tbody th { text-align: left; }
                     32:    table td, table th { border-left: solid; border-right: solid; border-bottom: solid thin; vertical-align: top; padding: 0.2em; }
                     33:    blockquote { margin: 0 0 0 2em; border: 0; padding: 0; font-style: italic; }
                     34: 
                     35:    .bad, .bad *:not(.XXX) { color: gray; border-color: gray; background: transparent; }
                     36:    .matrix, .matrix td { border: none; text-align: right; }
                     37:    .matrix { margin-left: 2em; }
                     38:    .dice-example { border-collapse: collapse; border-style: hidden solid solid hidden; border-width: thin; margin-left: 3em; }
                     39:    .dice-example caption { width: 30em; font-size: smaller; font-style: italic; padding: 0.75em 0; text-align: left; }
                     40:    .dice-example td, .dice-example th { border: solid thin; width: 1.35em; height: 1.05em; text-align: center; padding: 0; }
                     41: 
                     42:    .toc dfn, h1 dfn, h2 dfn, h3 dfn, h4 dfn, h5 dfn, h6 dfn { font: inherit; }
1.96      mike       43:    img.extra, p.overview { float: right; }
1.94      mike       44:    pre.idl { border: solid thin; background: #EEEEEE; color: black; padding: 0.5em 1em; position: relative; }
1.1       mike       45:    pre.idl :link, pre.idl :visited { color: inherit; background: transparent; }
1.94      mike       46:    pre.idl::before { content: "IDL"; font: bold small sans-serif; padding: 0.5em; background: white; position: absolute; top: 0; margin: -1px 0 0 -4em; width: 1.5em; border: thin solid; border-radius: 0 0 0 0.5em }
1.1       mike       47:    pre.css { border: solid thin; background: #FFFFEE; color: black; padding: 0.5em 1em; }
                     48:    pre.css:first-line { color: #AAAA50; }
                     49:    dl.domintro { color: green; margin: 2em 0 2em 2em; padding: 0.5em 1em; border: none; background: #DDFFDD; }
                     50:    hr + dl.domintro, div.impl + dl.domintro { margin-top: 2.5em; margin-bottom: 1.5em; }
                     51:    dl.domintro dt, dl.domintro dt * { color: black; text-decoration: none; }
                     52:    dl.domintro dd { margin: 0.5em 0 1em 2em; padding: 0; }
                     53:    dl.domintro dd p { margin: 0.5em 0; }
1.124     mike       54:    dl.domintro:before { display: table; margin: -1em -0.5em -0.5em auto; width: auto; content: 'This box is non-normative. Implementation requirements are given below this box.'; color: black; font-style: italic; border: solid 2px; background: white; padding: 0 0.25em; }
1.1       mike       55:    dl.switch { padding-left: 2em; }
                     56:    dl.switch > dt { text-indent: -1.5em; }
                     57:    dl.switch > dt:before { content: '\21AA'; padding: 0 0.5em 0 0; display: inline-block; width: 1em; text-align: right; line-height: 0.5em; }
                     58:    dl.triple { padding: 0 0 0 1em; }
                     59:    dl.triple dt, dl.triple dd { margin: 0; display: inline }
                     60:    dl.triple dt:after { content: ':'; }
                     61:    dl.triple dd:after { content: '\A'; white-space: pre; }
                     62:    .diff-old { text-decoration: line-through; color: silver; background: transparent; }
                     63:    .diff-chg, .diff-new { text-decoration: underline; color: green; background: transparent; }
                     64:    a .diff-new { border-bottom: 1px blue solid; }
                     65: 
                     66:    h2 { page-break-before: always; }
                     67:    h1, h2, h3, h4, h5, h6 { page-break-after: avoid; }
                     68:    h1 + h2, hr + h2.no-toc { page-break-before: auto; }
                     69: 
1.26      mike       70:    p  > span:not([title=""]):not([class="XXX"]):not([class="impl"]):not([class="note"]),
                     71:    li > span:not([title=""]):not([class="XXX"]):not([class="impl"]):not([class="note"]), { border-bottom: solid #9999CC; }
1.1       mike       72: 
                     73:    div.head { margin: 0 0 1em; padding: 1em 0 0 0; }
                     74:    div.head p { margin: 0; }
                     75:    div.head h1 { margin: 0; }
                     76:    div.head .logo { float: right; margin: 0 1em; }
                     77:    div.head .logo img { border: none } /* remove border from top image */
                     78:    div.head dl { margin: 1em 0; }
                     79:    div.head p.copyright, div.head p.alt { font-size: x-small; font-style: oblique; margin: 0; }
                     80: 
                     81:    body > .toc > li { margin-top: 1em; margin-bottom: 1em; }
                     82:    body > .toc.brief > li { margin-top: 0.35em; margin-bottom: 0.35em; }
                     83:    body > .toc > li > * { margin-bottom: 0.5em; }
                     84:    body > .toc > li > * > li > * { margin-bottom: 0.25em; }
                     85:    .toc, .toc li { list-style: none; }
                     86: 
                     87:    .brief { margin-top: 1em; margin-bottom: 1em; line-height: 1.1; }
                     88:    .brief li { margin: 0; padding: 0; }
                     89:    .brief li p { margin: 0; padding: 0; }
                     90: 
                     91:    .category-list { margin-top: -0.75em; margin-bottom: 1em; line-height: 1.5; }
                     92:    .category-list::before { content: '\21D2\A0'; font-size: 1.2em; font-weight: 900; }
                     93:    .category-list li { display: inline; }
                     94:    .category-list li:not(:last-child)::after { content: ', '; }
                     95:    .category-list li > span, .category-list li > a { text-transform: lowercase; }
                     96:    .category-list li * { text-transform: none; } /* don't affect <code> nested in <a> */
                     97: 
                     98:    .XXX { color: #E50000; background: white; border: solid red; padding: 0.5em; margin: 1em 0; }
                     99:    .XXX > :first-child { margin-top: 0; }
                    100:    p .XXX { line-height: 3em; }
                    101:    .annotation { border: solid thin black; background: #0C479D; color: white; position: relative; margin: 8px 0 20px 0; }
                    102:    .annotation:before { position: absolute; left: 0; top: 0; width: 100%; height: 100%; margin: 6px -6px -6px 6px; background: #333333; z-index: -1; content: ''; }
                    103:    .annotation :link, .annotation :visited { color: inherit; }
                    104:    .annotation :link:hover, .annotation :visited:hover { background: transparent; }
                    105:    .annotation span { border: none ! important; }
                    106:    .note { color: green; background: transparent; font-family: sans-serif; }
                    107:    .warning { color: red; background: transparent; }
                    108:    .note, .warning { font-weight: bolder; font-style: italic; }
1.83      mike      109:    .note em, .warning em, .note i, .warning i { font-style: normal; }
1.1       mike      110:    p.note, div.note { padding: 0.5em 2em; }
                    111:    span.note { padding: 0 2em; }
                    112:    .note p:first-child, .warning p:first-child { margin-top: 0; }
                    113:    .note p:last-child, .warning p:last-child { margin-bottom: 0; }
                    114:    .warning:before { font-style: normal; }
                    115:    p.note:before { content: 'Note: '; }
                    116:    p.warning:before { content: '\26A0 Warning! '; }
                    117: 
                    118:    .bookkeeping:before { display: block; content: 'Bookkeeping details'; font-weight: bolder; font-style: italic; }
                    119:    .bookkeeping { font-size: 0.8em; margin: 2em 0; }
                    120:    .bookkeeping p { margin: 0.5em 2em; display: list-item; list-style: square; }
1.12      mike      121:    .bookkeeping dt { margin: 0.5em 2em 0; }
                    122:    .bookkeeping dd { margin: 0 3em 0.5em; }
1.1       mike      123: 
                    124:    h4 { position: relative; z-index: 3; }
                    125:    h4 + .element, h4 + div + .element { margin-top: -2.5em; padding-top: 2em; }
                    126:    .element {
                    127:      background: #EEEEFF;
                    128:      color: black;
                    129:      margin: 0 0 1em 0.15em;
                    130:      padding: 0 1em 0.25em 0.75em;
                    131:      border-left: solid #9999FF 0.25em;
                    132:      position: relative;
                    133:      z-index: 1;
                    134:    }
                    135:    .element:before {
                    136:      position: absolute;
                    137:      z-index: 2;
                    138:      top: 0;
                    139:      left: -1.15em;
                    140:      height: 2em;
                    141:      width: 0.9em;
                    142:      background: #EEEEFF;
                    143:      content: ' ';
                    144:      border-style: none none solid solid;
                    145:      border-color: #9999FF;
                    146:      border-width: 0.25em;
                    147:    }
                    148: 
                    149:    .example { display: block; color: #222222; background: #FCFCFC; border-left: double; margin-left: 2em; padding-left: 1em; }
                    150:    td > .example:only-child { margin: 0 0 0 0.1em; }
                    151: 
                    152:    ul.domTree, ul.domTree ul { padding: 0 0 0 1em; margin: 0; }
                    153:    ul.domTree li { padding: 0; margin: 0; list-style: none; position: relative; }
                    154:    ul.domTree li li { list-style: none; }
                    155:    ul.domTree li:first-child::before { position: absolute; top: 0; height: 0.6em; left: -0.75em; width: 0.5em; border-style: none none solid solid; content: ''; border-width: 0.1em; }
                    156:    ul.domTree li:not(:last-child)::after { position: absolute; top: 0; bottom: -0.6em; left: -0.75em; width: 0.5em; border-style: none none solid solid; content: ''; border-width: 0.1em; }
                    157:    ul.domTree span { font-style: italic; font-family: serif; }
                    158:    ul.domTree .t1 code { color: purple; font-weight: bold; }
                    159:    ul.domTree .t2 { font-style: normal; font-family: monospace; }
                    160:    ul.domTree .t2 .name { color: black; font-weight: bold; }
                    161:    ul.domTree .t2 .value { color: blue; font-weight: normal; }
                    162:    ul.domTree .t3 code, .domTree .t4 code, .domTree .t5 code { color: gray; }
                    163:    ul.domTree .t7 code, .domTree .t8 code { color: green; }
                    164:    ul.domTree .t10 code { color: teal; }
                    165: 
                    166:    body.dfnEnabled dfn { cursor: pointer; }
                    167:    .dfnPanel {
                    168:      display: inline;
                    169:      position: absolute;
                    170:      z-index: 10;
                    171:      height: auto;
                    172:      width: auto;
                    173:      padding: 0.5em 0.75em;
                    174:      font: small sans-serif, Droid Sans Fallback;
                    175:      background: #DDDDDD;
                    176:      color: black;
                    177:      border: outset 0.2em;
                    178:    }
                    179:    .dfnPanel * { margin: 0; padding: 0; font: inherit; text-indent: 0; }
                    180:    .dfnPanel :link, .dfnPanel :visited { color: black; }
                    181:    .dfnPanel p { font-weight: bolder; }
                    182:    .dfnPanel * + p { margin-top: 0.25em; }
                    183:    .dfnPanel li { list-style-position: inside; }
                    184: 
                    185:    #configUI { position: absolute; z-index: 20; top: 10em; right: 1em; width: 11em; font-size: small; }
                    186:    #configUI p { margin: 0.5em 0; padding: 0.3em; background: #EEEEEE; color: black; border: inset thin; }
                    187:    #configUI p label { display: block; }
                    188:    #configUI #updateUI, #configUI .loginUI { text-align: center; }
                    189:    #configUI input[type=button] { display: block; margin: auto; }
1.11      mike      190: 
1.30      mike      191:    fieldset { margin: 1em; padding: 0.5em 1em; }
                    192:    fieldset > legend + * { margin-top: 0; }
1.21      mike      193:    fieldset > :last-child { margin-bottom: 0; }
1.30      mike      194:    fieldset p { margin: 0.5em 0; }
                    195: 
1.62      mike      196:   </style><link href="http://www.w3.org/StyleSheets/TR/W3C-ED" rel="stylesheet" type="text/css"><style type="text/css">
1.1       mike      197: 
                    198:    .applies thead th > * { display: block; }
                    199:    .applies thead code { display: block; }
                    200:    .applies tbody th { whitespace: nowrap; }
                    201:    .applies td { text-align: center; }
                    202:    .applies .yes { background: yellow; }
                    203: 
1.14      mike      204:    .matrix, .matrix td { border: hidden; text-align: right; }
1.1       mike      205:    .matrix { margin-left: 2em; }
                    206: 
                    207:    .dice-example { border-collapse: collapse; border-style: hidden solid solid hidden; border-width: thin; margin-left: 3em; }
                    208:    .dice-example caption { width: 30em; font-size: smaller; font-style: italic; padding: 0.75em 0; text-align: left; }
                    209:    .dice-example td, .dice-example th { border: solid thin; width: 1.35em; height: 1.05em; text-align: center; padding: 0; }
                    210: 
1.17      mike      211:    td.eg { border-width: thin; text-align: center; }
                    212: 
1.1       mike      213:    #table-example-1 { border: solid thin; border-collapse: collapse; margin-left: 3em; }
                    214:    #table-example-1 * { font-family: "Essays1743", serif; line-height: 1.01em; }
                    215:    #table-example-1 caption { padding-bottom: 0.5em; }
                    216:    #table-example-1 thead, #table-example-1 tbody { border: none; }
                    217:    #table-example-1 th, #table-example-1 td { border: solid thin; }
                    218:    #table-example-1 th { font-weight: normal; }
                    219:    #table-example-1 td { border-style: none solid; vertical-align: top; }
                    220:    #table-example-1 th { padding: 0.5em; vertical-align: middle; text-align: center; }
                    221:    #table-example-1 tbody tr:first-child td { padding-top: 0.5em; }
                    222:    #table-example-1 tbody tr:last-child td { padding-bottom: 1.5em; }
                    223:    #table-example-1 tbody td:first-child { padding-left: 2.5em; padding-right: 0; width: 9em; }
                    224:    #table-example-1 tbody td:first-child::after { content: leader(". "); }
                    225:    #table-example-1 tbody td { padding-left: 2em; padding-right: 2em; }
                    226:    #table-example-1 tbody td:first-child + td { width: 10em; }
                    227:    #table-example-1 tbody td:first-child + td ~ td { width: 2.5em; }
                    228:    #table-example-1 tbody td:first-child + td + td + td ~ td { width: 1.25em; }
                    229: 
                    230:    .apple-table-examples { border: none; border-collapse: separate; border-spacing: 1.5em 0em; width: 40em; margin-left: 3em; }
                    231:    .apple-table-examples * { font-family: "Times", serif; }
                    232:    .apple-table-examples td, .apple-table-examples th { border: none; white-space: nowrap; padding-top: 0; padding-bottom: 0; }
                    233:    .apple-table-examples tbody th:first-child { border-left: none; width: 100%; }
                    234:    .apple-table-examples thead th:first-child ~ th { font-size: smaller; font-weight: bolder; border-bottom: solid 2px; text-align: center; }
                    235:    .apple-table-examples tbody th::after, .apple-table-examples tfoot th::after { content: leader(". ") }
                    236:    .apple-table-examples tbody th, .apple-table-examples tfoot th { font: inherit; text-align: left; }
                    237:    .apple-table-examples td { text-align: right; vertical-align: top; }
                    238:    .apple-table-examples.e1 tbody tr:last-child td { border-bottom: solid 1px; }
                    239:    .apple-table-examples.e1 tbody + tbody tr:last-child td { border-bottom: double 3px; }
                    240:    .apple-table-examples.e2 th[scope=row] { padding-left: 1em; }
                    241:    .apple-table-examples sup { line-height: 0; }
                    242: 
                    243:    .details-example img { vertical-align: top; }
                    244: 
1.40      mike      245:    #base64-table {
                    246:      white-space: nowrap;
                    247:      font-size: 0.6em;
                    248:      column-width: 6em;
                    249:      column-count: 5;
                    250:      column-gap: 1em;
                    251:      -moz-column-width: 6em;
                    252:      -moz-column-count: 5;
                    253:      -moz-column-gap: 1em;
                    254:      -webkit-column-width: 6em;
                    255:      -webkit-column-count: 5;
                    256:      -webkit-column-gap: 1em;
                    257:    }
                    258:    #base64-table thead { display: none; }
                    259:    #base64-table * { border: none; }
                    260:    #base64-table tbody td:first-child:after { content: ':'; }
                    261:    #base64-table tbody td:last-child { text-align: right; }
                    262: 
1.1       mike      263:    #named-character-references-table {
1.19      mike      264:      white-space: nowrap;
1.1       mike      265:      font-size: 0.6em;
1.19      mike      266:      column-width: 30em;
1.1       mike      267:      column-gap: 1em;
1.19      mike      268:      -moz-column-width: 30em;
1.1       mike      269:      -moz-column-gap: 1em;
1.19      mike      270:      -webkit-column-width: 30em;
1.1       mike      271:      -webkit-column-gap: 1em;
                    272:    }
1.19      mike      273:    #named-character-references-table > table > tbody > tr > td:first-child + td,
1.1       mike      274:    #named-character-references-table > table > tbody > tr > td:last-child { text-align: center; }
                    275:    #named-character-references-table > table > tbody > tr > td:last-child:hover > span { position: absolute; top: auto; left: auto; margin-left: 0.5em; line-height: 1.2; font-size: 5em; border: outset; padding: 0.25em 0.5em; background: white; width: 1.25em; height: auto; text-align: center; }
1.19      mike      276:    #named-character-references-table > table > tbody > tr#entity-CounterClockwiseContourIntegral > td:first-child { font-size: 0.5em; }
1.1       mike      277: 
1.2       mike      278:    .glyph.control { color: red; }
                    279: 
1.4       mike      280:    @font-face {
                    281:      font-family: 'Essays1743';
                    282:      src: url('http://www.whatwg.org/specs/web-apps/current-work/fonts/Essays1743.ttf');
                    283:    }
                    284:    @font-face {
                    285:      font-family: 'Essays1743';
                    286:      font-weight: bold;
                    287:      src: url('http://www.whatwg.org/specs/web-apps/current-work/fonts/Essays1743-Bold.ttf');
                    288:    }
                    289:    @font-face {
                    290:      font-family: 'Essays1743';
                    291:      font-style: italic;
                    292:      src: url('http://www.whatwg.org/specs/web-apps/current-work/fonts/Essays1743-Italic.ttf');
                    293:    }
                    294:    @font-face {
                    295:      font-family: 'Essays1743';
                    296:      font-style: italic;
                    297:      font-weight: bold;
                    298:      src: url('http://www.whatwg.org/specs/web-apps/current-work/fonts/Essays1743-BoldItalic.ttf');
                    299:    }
                    300: 
1.61      mike      301:   </style><link href="data:text/css," id="complete" rel="stylesheet" title="Complete specification"><link href="data:text/css,.impl%20%7B%20display:%20none;%20%7D%0Ahtml%20%7B%20border:%20solid%20yellow;%20%7D%20.domintro:before%20%7B%20display:%20none;%20%7D" id="author" rel="alternate stylesheet" title="Author documentation only"><link href="data:text/css,.impl%20%7B%20background:%20%23FFEEEE;%20%7D%20.domintro:before%20%7B%20background:%20%23FFEEEE;%20%7D" id="highlight" rel="alternate stylesheet" title="Highlight implementation requirements"><script type="text/javascript">
1.45      mike      302:    function getCookie(name) {
                    303:      var params = location.search.substr(1).split("&");
                    304:      for (var index = 0; index < params.length; index++) {
                    305:        if (params[index] == name)
                    306:          return "1";
                    307:        var data = params[index].split("=");
                    308:        if (data[0] == name)
                    309:          return unescape(data[1]);
                    310:      }
                    311:      var cookies = document.cookie.split("; ");
                    312:      for (var index = 0; index < cookies.length; index++) {
                    313:        var data = cookies[index].split("=");
                    314:        if (data[0] == name)
                    315:          return unescape(data[1]);
                    316:      }
                    317:      return null;
                    318:    }
                    319:   </script>
1.1       mike      320:   <script src="link-fixup.js"></script>
1.146     mike      321:   <link href="the-img-element.html" title="4.8.1 The img element" rel="prev">
                    322:   <link href="index.html#contents" title="Table of contents" rel="contents">
                    323:   <link href="the-embed-element.html" title="4.8.3 The embed element" rel="next">
                    324:   </head><body class="split chapter"><div class="head" id="head">
1.1       mike      325:    <p><a href="http://www.w3.org/"><img alt="W3C" height="48" src="http://www.w3.org/Icons/w3c_home" width="72"></a></p>
1.3       mike      326: 
1.1       mike      327:    <h1>HTML5</h1>
1.148   ! mike      328:    <h2 class="no-num no-toc" id="a-vocabulary-and-associated-apis-for-html-and-xhtml">A vocabulary and associated APIs for HTML and XHTML</h2><p>This is revision 1.5471.</p>
1.146     mike      329: 
1.147     mike      330:    <h2 class="no-num no-toc" id="editor-s-draft-13-december-2011">Editor's Draft 13 December 2011</h2>
1.146     mike      331:    </div><nav class="prev_next">
                    332:    <a href="the-img-element.html">&#8592; 4.8.1 The img element</a> &#8211;
                    333:    <a href="index.html#contents">Table of contents</a> &#8211;
                    334:    <a href="the-embed-element.html">4.8.3 The embed element &#8594;</a>
                    335:   </nav>
1.1       mike      336: 
1.25      mike      337:   <h4 id="the-iframe-element"><span class="secno">4.8.2 </span>The <dfn><code>iframe</code></dfn> element</h4><dl class="element"><dt>Categories</dt>
1.1       mike      338:    <dd><a href="content-models.html#flow-content">Flow content</a>.</dd>
                    339:    <dd><a href="content-models.html#phrasing-content">Phrasing content</a>.</dd>
                    340:    <dd><a href="content-models.html#embedded-content">Embedded content</a>.</dd>
                    341:    <dd><a href="content-models.html#interactive-content">Interactive content</a>.</dd>
1.126     mike      342:    <dd><a href="content-models.html#palpable-content">Palpable content</a>.</dd>
1.16      mike      343:    <dt>Contexts in which this element can be used:</dt>
1.1       mike      344:    <dd>Where <a href="content-models.html#embedded-content">embedded content</a> is expected.</dd>
                    345:    <dt>Content model:</dt>
1.18      mike      346:    <dd>Text that conforms to <a href="#iframe-content-model">the requirements given in the prose</a>.</dd>
1.1       mike      347:    <dt>Content attributes:</dt>
1.146     mike      348:    <dd><a href="global-attributes.html#global-attributes">Global attributes</a></dd>
1.1       mike      349:    <dd><code title="attr-iframe-src"><a href="#attr-iframe-src">src</a></code></dd>
                    350:    <dd><code title="attr-iframe-srcdoc"><a href="#attr-iframe-srcdoc">srcdoc</a></code></dd>
                    351:    <dd><code title="attr-iframe-name"><a href="#attr-iframe-name">name</a></code></dd>
                    352:    <dd><code title="attr-iframe-sandbox"><a href="#attr-iframe-sandbox">sandbox</a></code></dd>
                    353:    <dd><code title="attr-iframe-seamless"><a href="#attr-iframe-seamless">seamless</a></code></dd>
1.146     mike      354:    <dd><code title="attr-dim-width"><a href="dimension-attributes.html#attr-dim-width">width</a></code></dd>
                    355:    <dd><code title="attr-dim-height"><a href="dimension-attributes.html#attr-dim-height">height</a></code></dd>
1.1       mike      356:    <dt>DOM interface:</dt>
                    357:    <dd>
                    358: <pre class="idl">interface <dfn id="htmliframeelement">HTMLIFrameElement</dfn> : <a href="elements.html#htmlelement">HTMLElement</a> {
                    359:            attribute DOMString <a href="#dom-iframe-src" title="dom-iframe-src">src</a>;
                    360:            attribute DOMString <a href="#dom-iframe-srcdoc" title="dom-iframe-srcdoc">srcdoc</a>;
                    361:            attribute DOMString <a href="#dom-iframe-name" title="dom-iframe-name">name</a>;
1.81      mike      362:   [PutForwards=<span title="dom-DOMSettableTokenList-value">value</span>] readonly attribute <a href="infrastructure.html#domsettabletokenlist">DOMSettableTokenList</a> <a href="#dom-iframe-sandbox" title="dom-iframe-sandbox">sandbox</a>;
1.1       mike      363:            attribute boolean <a href="#dom-iframe-seamless" title="dom-iframe-seamless">seamless</a>;
1.146     mike      364:            attribute DOMString <a href="dimension-attributes.html#dom-dim-width" title="dom-dim-width">width</a>;
                    365:            attribute DOMString <a href="dimension-attributes.html#dom-dim-height" title="dom-dim-height">height</a>;
1.68      mike      366:   readonly attribute Document? <a href="#dom-iframe-contentdocument" title="dom-iframe-contentDocument">contentDocument</a>;
                    367:   readonly attribute <a href="browsers.html#windowproxy">WindowProxy</a>? <a href="#dom-iframe-contentwindow" title="dom-iframe-contentWindow">contentWindow</a>;
1.1       mike      368: };</pre>
                    369:    </dd>
1.101     mike      370:   </dl><p>The <code><a href="#the-iframe-element">iframe</a></code> element <a href="rendering.html#represents">represents</a> a
1.1       mike      371:   <a href="browsers.html#nested-browsing-context">nested browsing context</a>.</p><p>The <dfn id="attr-iframe-src" title="attr-iframe-src"><code>src</code></dfn> attribute
                    372:   gives the address of a page that the <a href="browsers.html#nested-browsing-context">nested browsing
                    373:   context</a> is to contain. The attribute, if present, must be a
                    374:   <a href="urls.html#valid-non-empty-url-potentially-surrounded-by-spaces">valid non-empty URL potentially surrounded by
                    375:   spaces</a>.</p><p>The <dfn id="attr-iframe-srcdoc" title="attr-iframe-srcdoc"><code>srcdoc</code></dfn>
                    376:   attribute gives the content of the page that the <a href="browsers.html#nested-browsing-context">nested
1.32      mike      377:   browsing context</a> is to contain. The value of the attribute is
1.82      mike      378:   the source of <dfn id="an-iframe-srcdoc-document">an <code>iframe</code> <code title="attr-iframe-srcdoc">srcdoc</code> document</dfn>.</p><p>For <code><a href="#the-iframe-element">iframe</a></code> elements in <a href="infrastructure.html#html-documents">HTML documents</a>,
1.101     mike      379:   the attribute, if present, must have a value using <a href="syntax.html#syntax">the HTML
1.1       mike      380:   syntax</a> that consists of the following syntactic components,
1.101     mike      381:   in the given order:</p><ol><li>Any number of <a href="syntax.html#syntax-comments" title="syntax-comments">comments</a> and
1.1       mike      382:    <a href="common-microsyntaxes.html#space-character" title="space character">space characters</a>.</li>
                    383: 
1.101     mike      384:    <li>Optionally, a <a href="syntax.html#syntax-doctype" title="syntax-doctype">DOCTYPE</a>.
1.1       mike      385: 
1.101     mike      386:    </li><li>Any number of <a href="syntax.html#syntax-comments" title="syntax-comments">comments</a> and
1.1       mike      387:    <a href="common-microsyntaxes.html#space-character" title="space character">space characters</a>.</li>
                    388: 
1.146     mike      389:    <li>The root element, in the form of an <code><a href="the-html-element.html#the-html-element">html</a></code> <a href="syntax.html#syntax-elements" title="syntax-elements">element</a>.</li>
1.1       mike      390: 
1.101     mike      391:    <li>Any number of <a href="syntax.html#syntax-comments" title="syntax-comments">comments</a> and
1.1       mike      392:    <a href="common-microsyntaxes.html#space-character" title="space character">space characters</a>.</li>
                    393: 
1.82      mike      394:   </ol><p>For <code><a href="#the-iframe-element">iframe</a></code> elements in <a href="infrastructure.html#xml-documents">XML documents</a>,
1.1       mike      395:   the attribute, if present, must have a value that matches the
1.145     mike      396:   production labeled <code><a href="dom.html#document">document</a></code> in the XML
1.101     mike      397:   specification. <a href="references.html#refsXML">[XML]</a></p><p>If the <code title="attr-iframe-src"><a href="#attr-iframe-src">src</a></code> attribute and the
1.1       mike      398:   <code title="attr-iframe-srcdoc"><a href="#attr-iframe-srcdoc">srcdoc</a></code> attribute are both
                    399:   specified together, the <code title="attr-iframe-srcdoc"><a href="#attr-iframe-srcdoc">srcdoc</a></code>
                    400:   attribute takes priority. This allows authors to provide a fallback
                    401:   <a href="urls.html#url">URL</a> for legacy user agents that do not support the
                    402:   <code title="attr-iframe-srcdoc"><a href="#attr-iframe-srcdoc">srcdoc</a></code> attribute.</p><div class="impl">
                    403: 
                    404:   <p>When an <code><a href="#the-iframe-element">iframe</a></code> element is first <a href="infrastructure.html#insert-an-element-into-a-document" title="insert
                    405:   an element into a document">inserted into a document</a>, the
                    406:   user agent must create a <a href="browsers.html#nested-browsing-context">nested browsing context</a>, and
                    407:   then <a href="#process-the-iframe-attributes">process the <code>iframe</code> attributes</a> for the
                    408:   first time.</p>
                    409: 
                    410:   <p>Whenever an <code><a href="#the-iframe-element">iframe</a></code> element with a <a href="browsers.html#nested-browsing-context">nested
1.32      mike      411:   browsing context</a> has its <code title="attr-iframe-srcdoc"><a href="#attr-iframe-srcdoc">srcdoc</a></code> attribute set, changed, or
                    412:   removed, the user agent must <a href="#process-the-iframe-attributes">process the <code>iframe</code>
1.1       mike      413:   attributes</a>.</p>
                    414: 
                    415:   <p>Similarly, whenever an <code><a href="#the-iframe-element">iframe</a></code> element with a
                    416:   <a href="browsers.html#nested-browsing-context">nested browsing context</a> but with no <code title="attr-iframe-srcdoc"><a href="#attr-iframe-srcdoc">srcdoc</a></code> attribute specified has its
1.32      mike      417:   <code title="attr-iframe-src"><a href="#attr-iframe-src">src</a></code> attribute set, changed, or
                    418:   removed, the user agent must <a href="#process-the-iframe-attributes">process the <code>iframe</code>
1.46      mike      419:   attributes</a>.</p> 
1.1       mike      420:   <p>When the user agent is to <dfn id="process-the-iframe-attributes">process the <code>iframe</code>
                    421:   attributes</dfn>, it must run the first appropriate steps from the
                    422:   following list:</p>
                    423: 
                    424:   <dl class="switch"><dt>If the <code title="attr-iframe-srcdoc"><a href="#attr-iframe-srcdoc">srcdoc</a></code> attribute
                    425:    is specified</dt>
                    426: 
1.46      mike      427:    <dd><p><a href="history.html#navigate">Navigate</a> the element's
1.34      mike      428:    <a href="browsers.html#browsing-context">browsing context</a> to a resource whose
1.146     mike      429:    <a href="urls.html#content-type">Content-Type</a> is <code><a href="iana.html#text-html">text/html</a></code>, whose
1.34      mike      430:    <a href="urls.html#url">URL</a> is <code><a href="urls.html#about:srcdoc">about:srcdoc</a></code>, and whose data
                    431:    consists of the value of the attribute. The resulting
1.145     mike      432:    <code><a href="dom.html#document">Document</a></code> must be considered <a href="#an-iframe-srcdoc-document">an
1.34      mike      433:    <code>iframe</code> <code title="attr-iframe-srcdoc">srcdoc</code>
                    434:    document</a>.</p></dd>
1.1       mike      435: 
                    436:    <dt>If the <code title="attr-iframe-src"><a href="#attr-iframe-src">src</a></code>
                    437:    attribute is specified but the <code title="attr-iframe-srcdoc"><a href="#attr-iframe-srcdoc">srcdoc</a></code> attribute is not</dt>
                    438: 
                    439:    <dd>
                    440: 
                    441:     <ol><li><p>If the value of the <code title="attr-iframe-src"><a href="#attr-iframe-src">src</a></code> attribute is the empty string,
                    442:      jump to the <i title="">empty</i> step below.</p></li>
                    443: 
                    444:      <li><p><a href="urls.html#resolve-a-url" title="resolve a url">Resolve</a> the value of
                    445:      the <code title="attr-iframe-src"><a href="#attr-iframe-src">src</a></code> attribute, relative
                    446:      to the <code><a href="#the-iframe-element">iframe</a></code> element.</p></li>
                    447: 
                    448:      <li><p>If that is not successful, then jump to the <i title="">empty</i> step below.</p></li>
                    449: 
                    450:      <li><p>If the resulting <a href="urls.html#absolute-url">absolute URL</a> is an
                    451:      <a href="infrastructure.html#ascii-case-insensitive">ASCII case-insensitive</a> match for the string
1.146     mike      452:      "<code><a href="urls.html#about:blank">about:blank</a></code>", and the user agent is processing this
1.1       mike      453:      <code><a href="#the-iframe-element">iframe</a></code>'s attributes for the first time, then jump to
                    454:      the <i title="">empty</i> step below. (In cases other than the
1.146     mike      455:      first time, <code><a href="urls.html#about:blank">about:blank</a></code> is loaded
1.1       mike      456:      normally.)</p></li>
                    457: 
1.46      mike      458:      <li><p><a href="history.html#navigate">Navigate</a> the element's
1.34      mike      459:      <a href="browsers.html#browsing-context">browsing context</a> to the resulting <a href="urls.html#absolute-url">absolute
1.1       mike      460:      URL</a>.</p></li>
                    461: 
                    462:     </ol><p><i>Empty</i>: When the steps above require the user agent to
                    463:     jump to the <i title="">empty</i> step, if the user agent is
                    464:     processing this <code><a href="#the-iframe-element">iframe</a></code>'s attributes for the first
                    465:     time, then the user agent must <a href="webappapis.html#queue-a-task">queue a task</a> to
1.66      mike      466:     <a href="webappapis.html#fire-a-simple-event">fire a simple event</a> named <code title="event-load">load</code> at the <code><a href="#the-iframe-element">iframe</a></code> element.
                    467:     (After jumping to this step, the above steps are not resumed.)
                    468:     <span class="note">No <code title="event-load">load</code> event
1.146     mike      469:     is fired at the <code><a href="urls.html#about:blank">about:blank</a></code> document
1.66      mike      470:     itself.</span></p>
1.1       mike      471: 
                    472:    </dd>
                    473: 
                    474:    <dt>Otherwise</dt>
                    475: 
                    476:    <dd>
                    477: 
                    478:     <p><a href="webappapis.html#queue-a-task">Queue a task</a> to <a href="webappapis.html#fire-a-simple-event">fire a simple event</a>
                    479:     named <code title="event-load">load</code> at the
                    480:     <code><a href="#the-iframe-element">iframe</a></code> element.</p>
                    481: 
                    482:    </dd>
                    483: 
                    484:   </dl><p>Any <a href="history.html#navigate" title="navigate">navigation</a> required of the user
                    485:   agent in the <a href="#process-the-iframe-attributes">process the <code>iframe</code> attributes</a>
                    486:   algorithm must be completed with the <code><a href="#the-iframe-element">iframe</a></code> element's
                    487:   document's <a href="browsers.html#browsing-context">browsing context</a> as the <a href="history.html#source-browsing-context">source
                    488:   browsing context</a>.</p>
                    489: 
1.8       mike      490:   <p>Furthermore, if the <a href="browsers.html#browsing-context">browsing context</a>'s <a href="history.html#session-history">session
1.145     mike      491:   history</a> contained only one <code><a href="dom.html#document">Document</a></code> when the
1.8       mike      492:   <a href="#process-the-iframe-attributes">process the <code>iframe</code> attributes</a> algorithm
1.146     mike      493:   was invoked, and that was the <code><a href="urls.html#about:blank">about:blank</a></code>
1.145     mike      494:   <code><a href="dom.html#document">Document</a></code> created when the <a href="browsers.html#browsing-context">browsing context</a>
1.8       mike      495:   was created, then any <a href="history.html#navigate" title="navigate">navigation</a>
                    496:   required of the user agent in that algorithm must be completed with
1.46      mike      497:   <a href="history.html#replacement-enabled">replacement enabled</a>.</p> 
1.1       mike      498:   </div><p class="note">If, when the element is created, the <code title="attr-iframe-srcdoc"><a href="#attr-iframe-srcdoc">srcdoc</a></code> attribute is not set, and
                    499:   the <code title="attr-iframe-src"><a href="#attr-iframe-src">src</a></code> attribute is either
                    500:   also not set or set but its value cannot be <a href="urls.html#resolve-a-url" title="resolve a
                    501:   url">resolved</a>, the browsing context will remain at the
1.146     mike      502:   initial <code><a href="urls.html#about:blank">about:blank</a></code> page.</p><p class="note">If the user <a href="history.html#navigate" title="navigate">navigates</a>
1.1       mike      503:   away from this page, the <code><a href="#the-iframe-element">iframe</a></code>'s corresponding
                    504:   <code><a href="browsers.html#windowproxy">WindowProxy</a></code> object will proxy new <code><a href="browsers.html#window">Window</a></code>
1.145     mike      505:   objects for new <code><a href="dom.html#document">Document</a></code> objects, but the <code title="attr-iframe-src"><a href="#attr-iframe-src">src</a></code> attribute will not change.</p><div class="impl">
1.9       mike      506: 
                    507:   <div class="note">
                    508: 
                    509:    <p><a href="infrastructure.html#remove-an-element-from-a-document" title="remove an element from a document">Removing</a>
1.145     mike      510:    an <code><a href="#the-iframe-element">iframe</a></code> from a <code><a href="dom.html#document">Document</a></code> does not cause
1.9       mike      511:    its <a href="browsers.html#browsing-context">browsing context</a> to be discarded. Indeed, an
                    512:    <code><a href="#the-iframe-element">iframe</a></code>'s <a href="browsers.html#browsing-context">browsing context</a> can survive its
1.145     mike      513:    original parent <code><a href="dom.html#document">Document</a></code> if its <code><a href="#the-iframe-element">iframe</a></code> is
                    514:    moved to another <code><a href="dom.html#document">Document</a></code>.</p>
1.9       mike      515: 
1.10      mike      516:    <p>On the other hand, if an <code><a href="#the-iframe-element">iframe</a></code> is <a href="infrastructure.html#remove-an-element-from-a-document" title="remove an element from a document">removed</a> from a
1.145     mike      517:    <code><a href="dom.html#document">Document</a></code> and is then subsequently garbage collected,
1.10      mike      518:    this will likely mean (in the absence of other references) that the
                    519:    <a href="browsers.html#child-browsing-context">child browsing context</a>'s <code><a href="browsers.html#windowproxy">WindowProxy</a></code>
                    520:    object will become eligble for garbage collection, which will then
                    521:    lead to that <a href="browsers.html#browsing-context">browsing context</a> being <a href="browsers.html#a-browsing-context-is-discarded" title="a
                    522:    browsing context is discarded">discarded</a>, which will then
1.145     mike      523:    lead to its <code><a href="dom.html#document">Document</a></code> being <a href="browsers.html#discard-a-document" title="discard a
1.9       mike      524:    document">discarded</a> also. This happens without notice to any
1.145     mike      525:    scripts running in that <code><a href="dom.html#document">Document</a></code>; for example, no
1.9       mike      526:    <code title="event-unload">unload</code> events are fired (the
1.10      mike      527:    "<a href="history.html#unload-a-document">unload a document</a>" steps are not run).</p>
1.9       mike      528: 
                    529:   </div>
                    530: 
                    531:   </div><div class="example">
1.1       mike      532: 
                    533:    <p>Here a blog uses the <code title="attr-iframe-srcdoc"><a href="#attr-iframe-srcdoc">srcdoc</a></code> attribute in conjunction
                    534:    with the <code title="attr-iframe-sandbox"><a href="#attr-iframe-sandbox">sandbox</a></code> and <code title="attr-iframe-seamless"><a href="#attr-iframe-seamless">seamless</a></code> attributes described
                    535:    below to provide users of user agents that support this feature
                    536:    with an extra layer of protection from script injection in the blog
                    537:    post comments:</p>
                    538: 
                    539:    <pre>&lt;article&gt;
                    540:  &lt;h1&gt;I got my own magazine!&lt;/h1&gt;
                    541:  &lt;p&gt;After much effort, I've finally found a publisher, and so now I
                    542:  have my own magazine! Isn't that awesome?! The first issue will come
                    543:  out in September, and we have articles about getting food, and about
                    544:  getting in boxes, it's going to be great!&lt;/p&gt;
                    545:  &lt;footer&gt;
1.145     mike      546:   &lt;p&gt;Written by &lt;a href="/users/cap"&gt;cap&lt;/a&gt;, 1 hour ago.
1.1       mike      547:  &lt;/footer&gt;
                    548:  &lt;article&gt;
1.145     mike      549:   &lt;footer&gt; Thirteen minutes ago, &lt;a href="/users/ch"&gt;ch&lt;/a&gt; wrote: &lt;/footer&gt;
1.33      mike      550:   &lt;iframe seamless sandbox srcdoc="&lt;p&gt;did you get a cover picture yet?"&gt;&lt;/iframe&gt;
1.1       mike      551:  &lt;/article&gt;
                    552:  &lt;article&gt;
1.145     mike      553:   &lt;footer&gt; Nine minutes ago, &lt;a href="/users/cap"&gt;cap&lt;/a&gt; wrote: &lt;/footer&gt;
1.33      mike      554:   &lt;iframe seamless sandbox srcdoc="&lt;p&gt;Yeah, you can see it &lt;a href=&amp;quot;/gallery?mode=cover&amp;amp;amp;page=1&amp;quot;&gt;in my gallery&lt;/a&gt;."&gt;&lt;/iframe&gt;
1.1       mike      555:  &lt;/article&gt;
                    556:  &lt;article&gt;
1.145     mike      557:   &lt;footer&gt; Five minutes ago, &lt;a href="/users/ch"&gt;ch&lt;/a&gt; wrote: &lt;/footer&gt;
1.33      mike      558:   &lt;iframe seamless sandbox srcdoc="&lt;p&gt;hey that's earl's table.
1.1       mike      559: &lt;p&gt;you should get earl&amp;amp;amp;me on the next cover."&gt;&lt;/iframe&gt;
                    560:  &lt;/article&gt;</pre>
                    561: 
                    562:    <p>Notice the way that quotes have to be escaped (otherwise the
1.101     mike      563:    <code title="attr-iframe-srcdoc"><a href="#attr-iframe-srcdoc">srcdoc</a></code> attribute would end
                    564:    prematurely), and the way raw ampersands (e.g. in URLs or in prose)
                    565:    mentioned in the sandboxed content have to be <em>doubly</em>
                    566:    escaped &#8212; once so that the ampersand is preserved when
                    567:    originally parsing the <code title="attr-iframe-srcdoc"><a href="#attr-iframe-srcdoc">srcdoc</a></code> attribute, and once more
1.1       mike      568:    to prevent the ampersand from being misinterpreted when parsing the
                    569:    sandboxed content.</p>
                    570: 
1.101     mike      571:   </div><p class="note">In <a href="syntax.html#syntax">the HTML syntax</a>, authors need only
1.1       mike      572:   remember to use U+0022 QUOTATION MARK characters (") to wrap the
                    573:   attribute contents and then to escape all U+0022 QUOTATION MARK (")
                    574:   and U+0026 AMPERSAND (&amp;) characters, and to specify the <code title="attr-iframe-sandbox"><a href="#attr-iframe-sandbox">sandbox</a></code> attribute, to ensure safe
1.141     mike      575:   embedding of content.</p><p class="note">Due to restrictions of <a href="the-xhtml-syntax.html#the-xhtml-syntax">the XHTML
                    576:   syntax</a>, in XML the U+003C LESS-THAN SIGN character (&lt;)
                    577:   needs to be escaped as well. In order to prevent <a href="http://www.w3.org/TR/REC-xml/#AVNormalize">attribute-value
1.39      mike      578:   normalization</a>, some of XML's whitespace characters &#8212;
1.52      mike      579:   specifically U+0009 CHARACTER TABULATION (tab), U+000A LINE FEED
1.39      mike      580:   (LF), and U+000D CARRIAGE RETURN (CR) &#8212; also need to be
1.101     mike      581:   escaped. <a href="references.html#refsXML">[XML]</a></p><hr><p>The <dfn id="attr-iframe-name" title="attr-iframe-name"><code>name</code></dfn>
1.1       mike      582:   attribute, if present, must be a <a href="browsers.html#valid-browsing-context-name">valid browsing context
                    583:   name</a>. The given value is used to name the <a href="browsers.html#nested-browsing-context">nested
                    584:   browsing context</a>. <span class="impl">When the browsing
                    585:   context is created, if the attribute is present, the <a href="browsers.html#browsing-context-name">browsing
                    586:   context name</a> must be set to the value of this attribute;
                    587:   otherwise, the <a href="browsers.html#browsing-context-name">browsing context name</a> must be set to the
                    588:   empty string.</span></p><div class="impl">
                    589: 
                    590:   <p>Whenever the <code title="attr-iframe-name"><a href="#attr-iframe-name">name</a></code> attribute
                    591:   is set, the nested <a href="browsers.html#browsing-context">browsing context</a>'s <a href="browsers.html#browsing-context-name" title="browsing context name">name</a> must be changed to the new
                    592:   value. If the attribute is removed, the <a href="browsers.html#browsing-context-name">browsing context
                    593:   name</a> must be set to the empty string.</p>
                    594: 
                    595:   <p>When content loads in an <code><a href="#the-iframe-element">iframe</a></code>, after any <code title="event-load">load</code> events are fired within the content
                    596:   itself, the user agent must <a href="webappapis.html#queue-a-task">queue a task</a> to <a href="webappapis.html#fire-a-simple-event">fire
                    597:   a simple event</a> named <code title="event-load">load</code> at
                    598:   the <code><a href="#the-iframe-element">iframe</a></code> element. When content whose <a href="urls.html#url">URL</a>
                    599:   has the <a href="origin-0.html#same-origin">same origin</a> as the <code><a href="#the-iframe-element">iframe</a></code>
1.145     mike      600:   element's <code><a href="dom.html#document">Document</a></code> fails to load (e.g. due to a DNS
1.1       mike      601:   error, network error, or if the server returned a 4xx or 5xx status
1.146     mike      602:   code <a href="urls.html#concept-http-equivalent-codes" title="concept-http-equivalent-codes">or
1.1       mike      603:   equivalent</a>), then the user agent must <a href="webappapis.html#queue-a-task">queue a
                    604:   task</a> to <a href="webappapis.html#fire-a-simple-event">fire a simple event</a> named <code title="event-error">error</code> at the element instead. (This event
1.101     mike      605:   does not fire for <a href="parsing.html#parse-error" title="parse error">parse errors</a>,
1.1       mike      606:   script errors, or any errors for cross-origin resources.)</p>
                    607: 
                    608:   <p>The <a href="webappapis.html#task-source">task source</a> for these <a href="webappapis.html#concept-task" title="concept-task">tasks</a> is the <a href="webappapis.html#dom-manipulation-task-source">DOM manipulation
                    609:   task source</a>.</p>
                    610: 
                    611:   <p class="note">A <code title="event-load">load</code> event is also
                    612:   fired at the <code><a href="#the-iframe-element">iframe</a></code> element when it is created if no
                    613:   other data is loaded in it.</p>
                    614: 
                    615:   <p>When there is an <a href="dom.html#active-parser">active parser</a> in the
                    616:   <code><a href="#the-iframe-element">iframe</a></code>, and when anything in the <code><a href="#the-iframe-element">iframe</a></code> is
1.101     mike      617:   <a href="the-end.html#delay-the-load-event" title="delay the load event">delaying the load event</a> of
1.1       mike      618:   the <code><a href="#the-iframe-element">iframe</a></code>'s <a href="browsers.html#browsing-context">browsing context</a>'s
                    619:   <a href="browsers.html#active-document">active document</a>, the <code><a href="#the-iframe-element">iframe</a></code> must
1.101     mike      620:   <a href="the-end.html#delay-the-load-event">delay the load event</a> of its document.</p>
1.1       mike      621: 
                    622:   <p class="note">If, during the handling of the <code title="event-load">load</code> event, the <a href="browsers.html#browsing-context">browsing
1.101     mike      623:   context</a> in the <code><a href="#the-iframe-element">iframe</a></code> is again <a href="history.html#navigate" title="navigate">navigated</a>, that will further <a href="the-end.html#delay-the-load-event">delay the
1.1       mike      624:   load event</a>.</p>
                    625: 
                    626:   </div><hr><p>The <dfn id="attr-iframe-sandbox" title="attr-iframe-sandbox"><code>sandbox</code></dfn>
                    627:   attribute, when specified, enables a set of extra restrictions on
                    628:   any content hosted by the <code><a href="#the-iframe-element">iframe</a></code>. Its value must be an
1.20      mike      629:   <a href="common-microsyntaxes.html#unordered-set-of-unique-space-separated-tokens">unordered set of unique space-separated tokens</a> that are
1.77      mike      630:   <a href="infrastructure.html#ascii-case-insensitive">ASCII case-insensitive</a>. The allowed values are
1.1       mike      631:   <code title="attr-iframe-sandbox-allow-forms"><a href="#attr-iframe-sandbox-allow-forms">allow-forms</a></code>,
1.77      mike      632:   <code title="attr-iframe-sandbox-allow-same-origin"><a href="#attr-iframe-sandbox-allow-same-origin">allow-same-origin</a></code>,
                    633:   <code title="attr-iframe-sandbox-allow-scripts"><a href="#attr-iframe-sandbox-allow-scripts">allow-scripts</a></code>, and
                    634:   <code title="attr-iframe-sandbox-allow-top-navigation"><a href="#attr-iframe-sandbox-allow-top-navigation">allow-top-navigation</a></code>.
                    635: 
                    636:   When the attribute is set, the content is treated as being from a
                    637:   unique <a href="origin-0.html#origin">origin</a>, forms and scripts are disabled, links
                    638:   are prevented from targeting other <a href="browsers.html#browsing-context" title="browsing
1.114     mike      639:   context">browsing contexts</a>, and plugins are secured. The
1.1       mike      640:   <code title="attr-iframe-sandbox-allow-same-origin"><a href="#attr-iframe-sandbox-allow-same-origin">allow-same-origin</a></code>
                    641:   keyword allows the content to be treated as being from the same
                    642:   origin instead of forcing it into a unique origin, the <code title="attr-iframe-sandbox-allow-top-navigation"><a href="#attr-iframe-sandbox-allow-top-navigation">allow-top-navigation</a></code>
                    643:   keyword allows the content to <a href="history.html#navigate">navigate</a> its
                    644:   <a href="browsers.html#top-level-browsing-context">top-level browsing context</a>, and the <code title="attr-iframe-sandbox-allow-forms"><a href="#attr-iframe-sandbox-allow-forms">allow-forms</a></code> and <code title="attr-iframe-sandbox-allow-scripts"><a href="#attr-iframe-sandbox-allow-scripts">allow-scripts</a></code>
                    645:   keywords re-enable forms and scripts respectively (though scripts
1.77      mike      646:   are still prevented from creating popups).</p><p class="warning">Setting both the
                    647:   <code title="attr-iframe-sandbox-allow-scripts"><a href="#attr-iframe-sandbox-allow-scripts">allow-scripts</a></code> and
1.1       mike      648:   <code title="attr-iframe-sandbox-allow-same-origin"><a href="#attr-iframe-sandbox-allow-same-origin">allow-same-origin</a></code>
                    649:   keywords together when the embedded page has the <a href="origin-0.html#same-origin">same
                    650:   origin</a> as the page containing the <code><a href="#the-iframe-element">iframe</a></code> allows
                    651:   the embedded page to simply remove the <code title="attr-iframe-sandbox"><a href="#attr-iframe-sandbox">sandbox</a></code> attribute.</p><p class="warning">Sandboxing hostile content is of minimal help if
                    652:   an attacker can convince the user to just visit the hostile content
                    653:   directly, rather than in the <code><a href="#the-iframe-element">iframe</a></code>. To limit the
                    654:   damage that can be caused by hostile HTML content, it should be
1.127     mike      655:   served from a separate dedicated domain.</p><div class="impl">
1.1       mike      656: 
1.46      mike      657:   
1.1       mike      658:   <p>While the <code title="attr-iframe-sandbox"><a href="#attr-iframe-sandbox">sandbox</a></code>
                    659:   attribute is specified, the <code><a href="#the-iframe-element">iframe</a></code> element's
                    660:   <a href="browsers.html#nested-browsing-context">nested browsing context</a> must have the flags given in
                    661:   the following list set.  In addition, any browsing contexts <a href="browsers.html#nested-browsing-context" title="nested browsing context">nested</a> within an
                    662:   <code><a href="#the-iframe-element">iframe</a></code>, either directly or indirectly, must have all
                    663:   the flags set on them as were set on the <code><a href="#the-iframe-element">iframe</a></code>'s
1.145     mike      664:   <code><a href="dom.html#document">Document</a></code>'s <a href="browsers.html#browsing-context">browsing context</a> when the
                    665:   <code><a href="#the-iframe-element">iframe</a></code>'s <code><a href="dom.html#document">Document</a></code> was created.</p>
1.1       mike      666: 
                    667:   <dl><dt>The <dfn id="sandboxed-navigation-browsing-context-flag">sandboxed navigation browsing context flag</dfn></dt>
                    668: 
                    669:    <dd>
                    670: 
                    671:     <p>This flag <a href="history.html#sandboxLinks">prevents content from
                    672:     navigating browsing contexts other than the sandboxed browsing
                    673:     context itself</a> (or browsing contexts further nested inside
                    674:     it), and the <a href="browsers.html#top-level-browsing-context">top-level browsing context</a> (which is
                    675:     protected by the <a href="#sandboxed-top-level-navigation-browsing-context-flag">sandboxed top-level navigation browsing
                    676:     context flag</a> defined next).</p>
                    677: 
                    678:     <p>This flag also <a href="browsers.html#sandboxWindowOpen">prevents content
                    679:     from creating new auxiliary browsing contexts</a>, e.g. using the
1.72      mike      680:     <code title="attr-hyperlink-target"><a href="links.html#attr-hyperlink-target">target</a></code> attribute, the
1.146     mike      681:     <code title="dom-open"><a href="browsers.html#dom-open">window.open()</a></code> method, or the <code title="dom-showModalDialog"><a href="user-prompts.html#dom-showmodaldialog">showModalDialog()</a></code> method.</p>
1.1       mike      682: 
                    683:    </dd>
                    684: 
                    685: 
                    686:    <dt>The <dfn id="sandboxed-top-level-navigation-browsing-context-flag">sandboxed top-level navigation browsing context
                    687:    flag</dfn>, unless the <code title="attr-iframe-sandbox"><a href="#attr-iframe-sandbox">sandbox</a></code> attribute's value, when
                    688:    <a href="common-microsyntaxes.html#split-a-string-on-spaces" title="split a string on spaces">split on spaces</a>, is
                    689:    found to have the <dfn id="attr-iframe-sandbox-allow-top-navigation" title="attr-iframe-sandbox-allow-top-navigation"><code>allow-top-navigation</code></dfn>
                    690:    keyword set</dt>
                    691: 
                    692:    <dd>
                    693: 
                    694:     <p>This flag <a href="history.html#sandboxLinks">prevents content from
                    695:     navigating their <span>top-level browsing context</span></a>.</p>
                    696: 
                    697:     <p>When the <code title="attr-iframe-sandbox-allow-top-navigation"><a href="#attr-iframe-sandbox-allow-top-navigation">allow-top-navigation</a></code>
                    698:     is set, content can navigate its <a href="browsers.html#top-level-browsing-context">top-level browsing
                    699:     context</a>, but other <a href="browsers.html#browsing-context" title="browsing context">browsing
                    700:     contexts</a> are still protected by the <a href="#sandboxed-navigation-browsing-context-flag">sandboxed
                    701:     navigation browsing context flag</a> defined above.</p>
                    702: 
                    703:    </dd>
                    704: 
                    705: 
                    706:    <dt>The <dfn id="sandboxed-plugins-browsing-context-flag">sandboxed plugins browsing context flag</dfn></dt>
                    707: 
                    708:    <dd>
                    709: 
1.146     mike      710:     <p>This flag prevents content from instantiating <a href="infrastructure.html#plugin" title="plugin">plugins</a>, whether using <a href="the-embed-element.html#sandboxPluginEmbed">the <code>embed</code> element</a>, <a href="the-object-element.html#sandboxPluginObject">the <code>object</code> element</a>,
1.101     mike      711:     <a href="obsolete.html#sandboxPluginApplet">the <code>applet</code>
1.1       mike      712:     element</a>, or through <a href="history.html#sandboxPluginNavigate">navigation</a> of a <a href="browsers.html#nested-browsing-context">nested
1.114     mike      713:     browsing context</a>, unless those <a href="infrastructure.html#plugin" title="plugin">plugins</a> can be <a href="infrastructure.html#concept-plugin-secure" title="concept-plugin-secure">secured</a>.</p>
1.1       mike      714: 
                    715:    </dd>
                    716: 
                    717: 
                    718:    <dt>The <dfn id="sandboxed-seamless-iframes-flag">sandboxed seamless iframes flag</dfn></dt>
                    719: 
                    720:    <dd>
                    721: 
                    722:     <p>This flag prevents content from using the <code title="attr-iframe-seamless"><a href="#attr-iframe-seamless">seamless</a></code> attribute on
                    723:     descendant <code><a href="#the-iframe-element">iframe</a></code> elements.</p>
                    724: 
                    725:     <p class="note">This prevents a page inserted using the <code title="attr-iframe-sandbox-allow-same-origin"><a href="#attr-iframe-sandbox-allow-same-origin">allow-same-origin</a></code>
                    726:     keyword from using a CSS-selector-based method of probing the DOM
                    727:     of other pages on the same site (in particular, pages that contain
                    728:     user-sensitive information).</p>
                    729: 
1.46      mike      730:     
1.1       mike      731: 
                    732:    </dd>
                    733: 
                    734: 
                    735:    <dt>The <dfn id="sandboxed-origin-browsing-context-flag">sandboxed origin browsing context flag</dfn>, unless
                    736:    the <code title="attr-iframe-sandbox"><a href="#attr-iframe-sandbox">sandbox</a></code> attribute's
                    737:    value, when <a href="common-microsyntaxes.html#split-a-string-on-spaces" title="split a string on spaces">split on
                    738:    spaces</a>, is found to have the <dfn id="attr-iframe-sandbox-allow-same-origin" title="attr-iframe-sandbox-allow-same-origin"><code>allow-same-origin</code></dfn>
                    739:    keyword set</dt>
                    740: 
                    741:    <dd>
                    742: 
                    743:     <p>This flag <a href="origin-0.html#sandboxOrigin">forces content into a unique
                    744:     origin</a>, thus preventing it from accessing other content from
                    745:     the same <a href="origin-0.html#origin">origin</a>.</p>
                    746: 
                    747:     <p>This flag also <a href="dom.html#sandboxCookies">prevents script from
                    748:     reading from or writing to the <code title="dom-document-cookie">document.cookie</code> IDL
1.38      mike      749:     attribute</a>, and blocks access to <code title="dom-localStorage">localStorage</code>.
1.1       mike      750:     
1.101     mike      751:     <a href="references.html#refsWEBSTORAGE">[WEBSTORAGE]</a>
1.1       mike      752:     
                    753:     </p>
                    754: 
                    755:     <div class="note">
                    756: 
                    757:      <p>The <code title="attr-iframe-sandbox-allow-same-origin"><a href="#attr-iframe-sandbox-allow-same-origin">allow-same-origin</a></code>
                    758:      attribute is intended for two cases.</p>
                    759: 
                    760:      <p>First, it can be used to allow content from the same site to
                    761:      be sandboxed to disable scripting, while still allowing access to
                    762:      the DOM of the sandboxed content.</p>
                    763: 
                    764:      <p>Second, it can be used to embed content from a third-party
                    765:      site, sandboxed to prevent that site from opening popup windows,
                    766:      etc, without preventing the embedded page from communicating back
                    767:      to its originating site, using the database APIs to store data,
                    768:      etc.</p>
                    769: 
                    770:     </div>
                    771: 
                    772:    </dd>
                    773: 
                    774: 
                    775:    <dt>The <dfn id="sandboxed-forms-browsing-context-flag">sandboxed forms browsing context flag</dfn>, unless
                    776:    the <code title="attr-iframe-sandbox"><a href="#attr-iframe-sandbox">sandbox</a></code> attribute's
                    777:    value, when <a href="common-microsyntaxes.html#split-a-string-on-spaces" title="split a string on spaces">split on
                    778:    spaces</a>, is found to have the <dfn id="attr-iframe-sandbox-allow-forms" title="attr-iframe-sandbox-allow-forms"><code>allow-forms</code></dfn>
                    779:    keyword set</dt>
                    780: 
                    781:    <dd>
                    782: 
1.146     mike      783:     <p>This flag <a href="form-submission.html#sandboxSubmitBlocked">blocks form
1.1       mike      784:     submission</a>.</p>
                    785: 
                    786:    </dd>
                    787: 
                    788: 
                    789:    <dt>The <dfn id="sandboxed-scripts-browsing-context-flag">sandboxed scripts browsing context flag</dfn>, unless
                    790:    the <code title="attr-iframe-sandbox"><a href="#attr-iframe-sandbox">sandbox</a></code> attribute's
                    791:    value, when <a href="common-microsyntaxes.html#split-a-string-on-spaces" title="split a string on spaces">split on
                    792:    spaces</a>, is found to have the <dfn id="attr-iframe-sandbox-allow-scripts" title="attr-iframe-sandbox-allow-scripts"><code>allow-scripts</code></dfn>
                    793:    keyword set</dt>
                    794: 
                    795:    <dd>
                    796: 
                    797:     <p>This flag <a href="webappapis.html#sandboxScriptBlocked">blocks script
                    798:     execution</a>.</p>
                    799: 
                    800:    </dd>
                    801: 
                    802: 
                    803:    <dt>The <dfn id="sandboxed-automatic-features-browsing-context-flag">sandboxed automatic features browsing context
                    804:    flag</dfn>, unless the <code title="attr-iframe-sandbox"><a href="#attr-iframe-sandbox">sandbox</a></code> attribute's value, when
                    805:    <a href="common-microsyntaxes.html#split-a-string-on-spaces" title="split a string on spaces">split on spaces</a>, is
                    806:    found to have the <code title="attr-iframe-sandbox-allow-scripts"><a href="#attr-iframe-sandbox-allow-scripts">allow-scripts</a></code>
                    807:    keyword (defined above) set</dt>
                    808: 
                    809:    <dd>
                    810: 
                    811:     <p>This flag blocks features that trigger automatically, such as
1.146     mike      812:     <a href="media-elements.html#attr-media-autoplay" title="attr-media-autoplay">automatically playing a
                    813:     video</a> or <a href="attributes-common-to-form-controls.html#attr-fe-autofocus" title="attr-fe-autofocus">automatically
1.1       mike      814:     focusing a form control</a>. It is relaxed by the same flag as
                    815:     scripts, because when scripts are enabled these features are
                    816:     trivially possible anyway, and it would be unfortunate to force
                    817:     authors to use script to do them when sandboxed rather than
                    818:     allowing them to use the declarative features.</p>
                    819: 
                    820:    </dd>
                    821: 
                    822:   </dl><p>These flags must not be set unless the conditions listed above
                    823:   define them as being set.</p>
                    824: 
                    825:   <p class="warning">These flags only take effect when the
                    826:   <a href="browsers.html#nested-browsing-context">nested browsing context</a> of the <code><a href="#the-iframe-element">iframe</a></code> is
1.15      mike      827:   <a href="history.html#navigate" title="navigate">navigated</a>. Removing them, or removing
1.1       mike      828:   the entire <code title="attr-iframe-sandbox"><a href="#attr-iframe-sandbox">sandbox</a></code>
                    829:   attribute, has no effect on an already-loaded page.</p>
                    830: 
                    831:   </div><div class="example">
                    832: 
                    833:    <p>In this example, some completely-unknown, potentially hostile,
                    834:    user-provided HTML content is embedded in a page. Because it is
1.127     mike      835:    served from a separate domain, it is affected by all the normal
                    836:    cross-site restrictions. In addition, the embedded page has
                    837:    scripting disabled, plugins disabled, forms disabled, and it cannot
                    838:    navigate any frames or windows other than itself (or any frames or
                    839:    windows it itself embeds).</p>
1.1       mike      840: 
                    841:    <pre>&lt;p&gt;We're not scared of you! Here is your content, unedited:&lt;/p&gt;
1.127     mike      842: &lt;iframe sandbox src="http://usercontent.example.net/getusercontent.cgi?id=12193"&gt;&lt;/iframe&gt;</pre>
1.1       mike      843: 
1.127     mike      844:    <p class="warning">It is important to use a separate domain so that
                    845:    if the attacker convinces the user to visit that page directly, the
                    846:    page doesn't run in the context of the site's origin, which would
                    847:    make the user vulnerable to any attack found in the page.</p>
1.1       mike      848: 
                    849:   </div><div class="example">
                    850: 
                    851:    <p>In this example, a gadget from another site is embedded. The
                    852:    gadget has scripting and forms enabled, and the origin sandbox
                    853:    restrictions are lifted, allowing the gadget to communicate with
                    854:    its originating server. The sandbox is still useful, however, as it
                    855:    disables plugins and popups, thus reducing the risk of the user
                    856:    being exposed to malware and other annoyances.</p>
                    857: 
                    858:    <pre>&lt;iframe sandbox="allow-same-origin allow-forms allow-scripts"
                    859:         src="http://maps.example.com/embedded.html"&gt;&lt;/iframe&gt;</pre>
                    860: 
                    861:   </div><div class="example">
                    862: 
                    863:    <p>Suppose a file A contained the following fragment:</p>
                    864: 
                    865:    <pre>&lt;iframe sandbox="allow-same-origin allow-forms" src=B&gt;&lt;/iframe&gt;</pre>
                    866: 
                    867:    <p>Suppose that file B contained an iframe also:</p>
                    868: 
                    869:    <pre>&lt;iframe sandbox="allow-scripts" src=C&gt;&lt;/iframe&gt;</pre>
                    870: 
                    871:    <p>Further, suppose that file C contained a link:</p>
                    872: 
                    873:    <pre>&lt;a href=D&gt;Link&lt;/a&gt;</pre>
                    874: 
                    875:    <p>For this example, suppose all the files were served as
1.101     mike      876:    <code><a href="iana.html#text-html">text/html</a></code>.</p>
1.1       mike      877: 
                    878:    <p>Page C in this scenario has all the sandboxing flags
                    879:    set. Scripts are disabled, because the <code><a href="#the-iframe-element">iframe</a></code> in A has
                    880:    scripts disabled, and this overrides the <code title="attr-iframe-sandbox-allow-scripts"><a href="#attr-iframe-sandbox-allow-scripts">allow-scripts</a></code>
                    881:    keyword set on the <code><a href="#the-iframe-element">iframe</a></code> in B. Forms are also
                    882:    disabled, because the inner <code><a href="#the-iframe-element">iframe</a></code> (in B) does not
                    883:    have the <code title="attr-iframe-sandbox-allow-forms"><a href="#attr-iframe-sandbox-allow-forms">allow-forms</a></code> keyword
                    884:    set.</p>
                    885: 
1.142     mike      886:    <p>Suppose now that a script in A removes all the <code title="attr-iframe-sandbox"><a href="#attr-iframe-sandbox">sandbox</a></code> attributes in A
                    887:     and B. This would change nothing
                    888:    immediately. If the user clicked the link in C, loading page D into
                    889:    the <code><a href="#the-iframe-element">iframe</a></code> in B, page D would now act as if the
                    890:    <code><a href="#the-iframe-element">iframe</a></code> in B had the <code title="attr-iframe-sandbox-allow-same-origin"><a href="#attr-iframe-sandbox-allow-same-origin">allow-same-origin</a></code>
1.1       mike      891:    and <code title="attr-iframe-sandbox-allow-forms"><a href="#attr-iframe-sandbox-allow-forms">allow-forms</a></code> keywords
                    892:    set, because that was the state of the <a href="browsers.html#nested-browsing-context">nested browsing
                    893:    context</a> in the <code><a href="#the-iframe-element">iframe</a></code> in A when page B was
                    894:    loaded.</p>
                    895: 
                    896:    <p>Generally speaking, dynamically removing or changing the <code title="attr-iframe-sandbox"><a href="#attr-iframe-sandbox">sandbox</a></code> attribute is
                    897:    ill-advised, because it can make it quite hard to reason about what
                    898:    will be allowed and what will not.</p>
                    899: 
1.127     mike      900:   </div><p class="note">Potentially hostile files should not be served from
                    901:   the same server as the file containing the <code><a href="#the-iframe-element">iframe</a></code>
                    902:   element. Using a different domain ensures that scripts in the files
                    903:   are unable to attack the site, even if the user is tricked into
                    904:   visiting those pages directly, without the protection of the <code title="attr-iframe-sandbox"><a href="#attr-iframe-sandbox">sandbox</a></code> attribute.</p><p class="warning">If the <code title="attr-iframe-sandbox-allow-scripts"><a href="#attr-iframe-sandbox-allow-scripts">allow-scripts</a></code>
1.1       mike      905:   keyword is set along with <code title="attr-iframe-sandbox-allow-same-origin"><a href="#attr-iframe-sandbox-allow-same-origin">allow-same-origin</a></code>
                    906:   keyword, and the file is from the <a href="origin-0.html#same-origin">same origin</a> as the
1.145     mike      907:   <code><a href="#the-iframe-element">iframe</a></code>'s <code><a href="dom.html#document">Document</a></code>, then a script in the
1.1       mike      908:   "sandboxed" iframe could just reach out, remove the <code title="attr-iframe-sandbox"><a href="#attr-iframe-sandbox">sandbox</a></code> attribute, and then
                    909:   reload itself, effectively breaking out of the sandbox
1.46      mike      910:   altogether.</p><hr><p>The <dfn id="attr-iframe-seamless" title="attr-iframe-seamless"><code>seamless</code></dfn>
1.1       mike      911:   attribute is a <a href="common-microsyntaxes.html#boolean-attribute">boolean attribute</a>. When specified, it
                    912:   indicates that the <code><a href="#the-iframe-element">iframe</a></code> element's <a href="browsers.html#browsing-context">browsing
                    913:   context</a> is to be rendered in a manner that makes it appear to
                    914:   be part of the containing document (seamlessly included in the
                    915:   parent document). <span class="impl">Specifically, when the
                    916:   attribute is set on an <code><a href="#the-iframe-element">iframe</a></code> element whose owner
1.145     mike      917:   <code><a href="dom.html#document">Document</a></code>'s <a href="browsers.html#browsing-context">browsing context</a> did not have
1.1       mike      918:   the <a href="#sandboxed-seamless-iframes-flag">sandboxed seamless iframes flag</a> set when that
1.145     mike      919:   <code><a href="dom.html#document">Document</a></code> was created, and while either the
1.1       mike      920:   <a href="browsers.html#browsing-context">browsing context</a>'s <a href="browsers.html#active-document">active document</a> has the
                    921:   <a href="origin-0.html#same-origin">same origin</a> as the <code><a href="#the-iframe-element">iframe</a></code> element's
                    922:   document, or the <a href="browsers.html#browsing-context">browsing context</a>'s <a href="browsers.html#active-document">active
                    923:   document</a>'s <em><a href="dom.html#the-document-s-address" title="the document's
                    924:   address">address</a></em> has the <a href="origin-0.html#same-origin">same origin</a> as the
1.33      mike      925:   <code><a href="#the-iframe-element">iframe</a></code> element's document, or the <a href="browsers.html#browsing-context">browsing
                    926:   context</a>'s <a href="browsers.html#active-document">active document</a> is <a href="#an-iframe-srcdoc-document">an
                    927:   <code>iframe</code> <code title="attr-iframe-srcdoc">srcdoc</code>
                    928:   document</a>, the following requirements apply:</span></p><div class="impl">
1.1       mike      929: 
1.13      mike      930:   <ul><li><p>The user agent must set the <dfn id="seamless-browsing-context-flag">seamless browsing context
                    931:    flag</dfn> to true for that <a href="browsers.html#browsing-context">browsing context</a>. This
                    932:    will <a href="history.html#seamlessLinks">cause links to open in the parent
                    933:    browsing context</a> unless an <a href="browsers.html#explicit-self-navigation-override">explicit self-navigation
                    934:    override</a> is used (<code title="">target="_self"</code>).</p></li>
1.1       mike      935: 
                    936:    <li><p>In a CSS-supporting user agent: the user agent must add all
                    937:    the style sheets that apply to the <code><a href="#the-iframe-element">iframe</a></code> element to
                    938:    the cascade of the <a href="browsers.html#active-document">active document</a> of the
                    939:    <code><a href="#the-iframe-element">iframe</a></code> element's <a href="browsers.html#nested-browsing-context">nested browsing context</a>,
                    940:    at the appropriate cascade levels, before any style sheets
                    941:    specified by the document itself.</p></li>
                    942: 
                    943:    <li><p>In a CSS-supporting user agent: the user agent must, for the
                    944:    purpose of CSS property inheritance only, treat the root element of
                    945:    the <a href="browsers.html#active-document">active document</a> of the <code><a href="#the-iframe-element">iframe</a></code>
                    946:    element's <a href="browsers.html#nested-browsing-context">nested browsing context</a> as being a child of
                    947:    the <code><a href="#the-iframe-element">iframe</a></code> element. (Thus inherited properties on the
                    948:    root element of the document in the <code><a href="#the-iframe-element">iframe</a></code> will
                    949:    inherit the computed values of those properties on the
                    950:    <code><a href="#the-iframe-element">iframe</a></code> element instead of taking their initial
                    951:    values.)</p></li>
                    952: 
                    953:    <li><p>In visual media, in a CSS-supporting user agent: the user agent
                    954:    should set the intrinsic width of the <code><a href="#the-iframe-element">iframe</a></code> to the
                    955:    width that the element would have if it was a non-replaced
                    956:    block-level element with 'width: auto'.</p></li>
                    957: 
                    958:    <li><p>In visual media, in a CSS-supporting user agent: the user
                    959:    agent should set the intrinsic height of the <code><a href="#the-iframe-element">iframe</a></code> to
                    960:    the height of the bounding box around the content rendered in the
                    961:    <code><a href="#the-iframe-element">iframe</a></code> at its current width (as given in the previous
                    962:    bullet point), as it would be if the scrolling position was such
                    963:    that the top of the viewport for the content rendered in the
                    964:    <code><a href="#the-iframe-element">iframe</a></code> was aligned with the origin of that content's
                    965:    canvas.</p></li>
                    966: 
                    967:    <li>
                    968: 
                    969:     <p>In visual media, in a CSS-supporting user agent: the user agent
                    970:     must force the height of the initial containing block of the
                    971:     <a href="browsers.html#active-document">active document</a> of the <a href="browsers.html#nested-browsing-context">nested browsing
                    972:     context</a> of the <code><a href="#the-iframe-element">iframe</a></code> to zero.</p>
                    973: 
                    974:     <p class="note">This is intended to get around the otherwise
                    975:     circular dependency of percentage dimensions that depend on the
                    976:     height of the containing block, thus affecting the height of the
                    977:     document's bounding box, thus affecting the height of the
                    978:     viewport, thus affecting the size of the initial containing
                    979:     block.</p>
                    980: 
                    981:    </li>
                    982: 
                    983:    <li><p>In speech media, the user agent should render the <a href="browsers.html#nested-browsing-context">nested
                    984:    browsing context</a> without announcing that it is a separate
                    985:    document.</p></li>
                    986: 
                    987:    <li>
                    988: 
                    989:     <p>User agents should, in general, act as if the <a href="browsers.html#active-document">active
                    990:     document</a> of the <code><a href="#the-iframe-element">iframe</a></code>'s <a href="browsers.html#nested-browsing-context">nested browsing
                    991:     context</a> was part of the document that the
1.35      mike      992:     <code><a href="#the-iframe-element">iframe</a></code> is in, if any.</p>
1.1       mike      993: 
                    994:     <p class="example">For example if the user agent supports listing
                    995:     all the links in a document, links in "seamlessly" nested
                    996:     documents would be included in that list without being
                    997:     significantly distinguished from links in the document itself.</p>
                    998: 
                    999:    </li>
                   1000: 
                   1001:   </ul><p>If the attribute is not specified, or if the <a href="origin-0.html#origin">origin</a>
                   1002:   conditions listed above are not met, then the user agent should
                   1003:   render the <a href="browsers.html#nested-browsing-context">nested browsing context</a> in a manner that is
                   1004:   clearly distinguishable as a separate <a href="browsers.html#browsing-context">browsing context</a>,
                   1005:   and the <a href="#seamless-browsing-context-flag">seamless browsing context flag</a> must be set to
                   1006:   false for that <a href="browsers.html#browsing-context">browsing context</a>.</p>
                   1007: 
                   1008:   <p class="warning">It is important that user agents recheck the
                   1009:   above conditions whenever the <a href="browsers.html#active-document">active document</a> of the
                   1010:   <a href="browsers.html#nested-browsing-context">nested browsing context</a> of the <code><a href="#the-iframe-element">iframe</a></code>
                   1011:   changes, such that the <a href="#seamless-browsing-context-flag">seamless browsing context flag</a>
                   1012:   gets unset if the <a href="browsers.html#nested-browsing-context">nested browsing context</a> is <a href="history.html#navigate" title="navigate">navigated</a> to another origin.</p>
                   1013: 
                   1014:   </div><p class="note">The attribute can be set or removed dynamically,
                   1015:   with the rendering updating in tandem.</p><div class="example">
                   1016: 
                   1017:    <p>In this example, the site's navigation is embedded using a
                   1018:    client-side include using an <code><a href="#the-iframe-element">iframe</a></code>. Any links in the
                   1019:    <code><a href="#the-iframe-element">iframe</a></code> will, in new user agents, be automatically
                   1020:    opened in the <code><a href="#the-iframe-element">iframe</a></code>'s parent browsing context; for
1.146     mike     1021:    legacy user agents, the site could also include a <code><a href="the-base-element.html#the-base-element">base</a></code>
                   1022:    element with a <code title="attr-base-target"><a href="the-base-element.html#attr-base-target">target</a></code>
1.1       mike     1023:    attribute with the value <code title="">_parent</code>. Similarly,
                   1024:    in new user agents the styles of the parent page will be
                   1025:    automatically applied to the contents of the frame, but to support
                   1026:    legacy user agents authors might wish to include the styles
                   1027:    explicitly.</p>
                   1028: 
                   1029:    <pre>&lt;nav&gt;&lt;iframe seamless src="nav.include.html"&gt;&lt;/iframe&gt;&lt;/nav&gt;</pre>
                   1030: 
1.146     mike     1031:   </div><hr><p>The <code><a href="#the-iframe-element">iframe</a></code> element supports <a href="dimension-attributes.html#dimension-attributes">dimension
1.1       mike     1032:   attributes</a> for cases where the embedded content has specific
                   1033:   dimensions (e.g. ad units have well-defined dimensions).</p><p>An <code><a href="#the-iframe-element">iframe</a></code> element never has <a href="content-models.html#fallback-content">fallback
                   1034:   content</a>, as it will always create a nested <a href="browsers.html#browsing-context">browsing
                   1035:   context</a>, regardless of whether the specified initial contents
                   1036:   are successfully used.</p><p>Descendants of <code><a href="#the-iframe-element">iframe</a></code> elements represent
                   1037:   nothing. (In legacy user agents that do not support
                   1038:   <code><a href="#the-iframe-element">iframe</a></code> elements, the contents would be parsed as markup
1.82      mike     1039:   that could act as fallback content.)</p><p id="iframe-content-model">When used in <a href="infrastructure.html#html-documents">HTML
1.18      mike     1040:   documents</a>, the allowed content model of <code><a href="#the-iframe-element">iframe</a></code>
1.101     mike     1041:   elements is text, except that invoking the <a href="the-end.html#html-fragment-parsing-algorithm">HTML fragment
1.18      mike     1042:   parsing algorithm</a> with the <code><a href="#the-iframe-element">iframe</a></code> element as the
1.101     mike     1043:   <var title="concept-frag-parse-context"><a href="the-end.html#concept-frag-parse-context">context</a></var> element and
1.48      mike     1044:   the text contents as the <var title="">input</var> must result in a
                   1045:   list of nodes that are all <a href="content-models.html#phrasing-content">phrasing content</a>, with no
1.101     mike     1046:   <a href="parsing.html#parse-error" title="parse error">parse errors</a> having occurred, with
1.146     mike     1047:   no <code><a href="the-script-element.html#the-script-element">script</a></code> elements being anywhere in the list or as
1.18      mike     1048:   descendants of elements in the list, and with all the elements in
                   1049:   the list (including their descendants) being themselves
1.82      mike     1050:   conforming.</p><p>The <code><a href="#the-iframe-element">iframe</a></code> element must be empty in <a href="infrastructure.html#xml-documents">XML
1.101     mike     1051:   documents</a>.</p><p class="note">The <a href="parsing.html#html-parser">HTML parser</a> treats markup inside
1.1       mike     1052:   <code><a href="#the-iframe-element">iframe</a></code> elements as text.</p><div class="impl">
                   1053: 
                   1054:   <p>The IDL attributes <dfn id="dom-iframe-src" title="dom-iframe-src"><code>src</code></dfn>, <dfn id="dom-iframe-srcdoc" title="dom-iframe-srcdoc"><code>srcdoc</code></dfn>, <dfn id="dom-iframe-name" title="dom-iframe-name"><code>name</code></dfn>, <dfn id="dom-iframe-sandbox" title="dom-iframe-sandbox"><code>sandbox</code></dfn>, and <dfn id="dom-iframe-seamless" title="dom-iframe-seamless"><code>seamless</code></dfn> must
                   1055:   <a href="common-dom-interfaces.html#reflect">reflect</a> the respective content attributes of the same
                   1056:   name.</p>
                   1057: 
                   1058:   <p>The <dfn id="dom-iframe-contentdocument" title="dom-iframe-contentDocument"><code>contentDocument</code></dfn>
1.145     mike     1059:   IDL attribute must return the <code><a href="dom.html#document">Document</a></code> object of the
1.1       mike     1060:   <a href="browsers.html#active-document">active document</a> of the <code><a href="#the-iframe-element">iframe</a></code> element's
                   1061:   <a href="browsers.html#nested-browsing-context">nested browsing context</a>.</p>
                   1062: 
                   1063:   <p>The <dfn id="dom-iframe-contentwindow" title="dom-iframe-contentWindow"><code>contentWindow</code></dfn>
                   1064:   IDL attribute must return the <code><a href="browsers.html#windowproxy">WindowProxy</a></code> object of the
                   1065:   <code><a href="#the-iframe-element">iframe</a></code> element's <a href="browsers.html#nested-browsing-context">nested browsing
                   1066:   context</a>.</p>
                   1067: 
                   1068:   </div><div class="example">
                   1069: 
                   1070:    <p>Here is an example of a page using an <code><a href="#the-iframe-element">iframe</a></code> to
                   1071:    include advertising from an advertising broker:</p>
                   1072: 
                   1073:    <pre>&lt;iframe src="http://ads.example.com/?customerid=923513721&amp;amp;format=banner"
                   1074:         width="468" height="60"&gt;&lt;/iframe&gt;</pre>
                   1075: 
                   1076:   </div></body></html>

Webmaster