HTML <frame> SRC-attribute - use html-code instead of URL

前端 未结 4 906
Happy的楠姐
Happy的楠姐 2021-02-05 16:32

Is there a way to use pure html-code to display inside a frame instead of having to link to a specific URL/file?

For example:

NOT like this

4条回答
  •  走了就别回头了
    2021-02-05 17:21

    In HTML5 there appears to be a way to do this:

    See here, supposedly this is the purpose of the new html5 srcdoc attribute.

    According to the MDN, it appears only chrome will honor the srcdoc attribute at this time.

    I wasn't able to get this attribute to work, so it's probably not a viable option at this time. As others suggested, using a div is probably a better solution.

提交回复
热议问题