javascript - iframe 的 srcdoc 总是 HTML 文档吗?

标签 javascript html iframe

我正在尝试解决 Chrome 的跨源问题,该问题是通过具有 src 属性的 iFrame 标记产生的,其中包含数据 uri。我想知道我是否可以使用 srcdoc 属性解决这个问题。这就是为什么我对 srcdoc 的默认内容类型 'text/html' 感到好奇的原因?

最佳答案

是的,默认内容类型实际上是 text/html。根据HTML5 specification ,

If the srcdoc attribute is specified:

Navigate the element's browsing context to a resource whose Content-Type is text/html, whose URL is about:srcdoc, and whose data consists of the value of the attribute. The resulting Document must be considered an iframe srcdoc document.

关于javascript - iframe 的 srcdoc 总是 HTML 文档吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37888846/

相关文章:

javascript - 将子 iframe 中的事件附加到父窗口中的处理程序

iframe - 在 IFrame 内使用 Facebook 连接(不是 Facebook 内的 Iframe)

javascript - JS : Get IDs of objects in specific order

php - MPDF 不显示正确的 CSS

javascript - 每次调用时,Google Script for loop 都会运行整个数组 - 寻找

jquery - 如何在 JWPlayer 中使用 WebVTT 文件创建成绩单?

html - 缩放时 Div 框移动

html - iframe 内的按钮不起作用

javascript - 按键和鼠标事件

javascript - 在 JSX 表达式中连接字符串和 HTML