我正在尝试解决 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/