为什么HTML5不包含将本地HTML加载到文档中的方式? [英] Why does HTML5 not include a way of loading local HTML into the document?

查看:108
本文介绍了为什么HTML5不包含将本地HTML加载到文档中的方式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

最近我已经想了很多。 HTML5 为什么不能真正允许您将HTML加载到文档中以分解HTML文件?



它支持 / em>其他所有资产(图片,视频,音频)。



是的,我们有 iframes 嵌入 objects 但它们是沙箱,并且不遵循文档其余部分的流程。



我想的是:

 < h2>我的精彩应用< / h2> 

< include src =leftPane.htmltype =text / html/>

< include src =main.htmltype =text / html/>

< include src =footer.htmltype =text / html/>

我希望有人向我解释这个。在几乎所有的Web应用程序中,我们使用某种形式的模板来分解HTML,为什么HTML5不仅仅包含它?



没有想法。



马特

解决方案

事实证明,这已经出现在WHATWG邮件列表中:客户端-side includes proposal :Shannon提出了你正在说的,解析器在加载文档片段时必须阻止的地方。 Ian Hickson拒绝了它,因为延迟成本太高。此外,它是许多Web服务器已经提供的一个简单功能,因此被认为不值得花费。



您可能想要使用无缝属性的 iframe ,这会导致整个文档被放置在文档中,但像任何块元素一样(从主机继承样式文件)。尽管如此,我认为它还不被许多浏览器支持。


I've thinking about this a lot lately. Why does HTML5 not really let you load HTML into your document to break up your HTML files?

It has support for nearly every other asset (images, videos, audio).

Yes we have iframes, embeds, and objects but they are sandboxed and don't follow the flow of the rest of the document.

I was thinking of something like:

<h2>My wonderful application</h2>

<include src = "leftPane.html" type = "text/html" />

<include src = "main.html" type = "text/html" />

<include src = "footer.html" type = "text/html" />

I would love for someone to explain this to me. In nearly every web application we make, we use some form of templating to break up our HTML, so why does HTML5 not just include it?

I'd appreciate your (flameless) thoughts.

Matt

解决方案

As it turns out, this has come up in the WHATWG mailing lists: Client-side includes proposal: Shannon proposed exactly what you are saying, where the parser has to block while loading document fragments. Ian Hickson rejected it because the latency cost is too high. Besides, it's a simple feature that many web servers already provide, so it was deemed not worth the cost.

You may instead want to investigate using the seamless attribute of iframe, which causes a full document to be placed within the document but act like any block element (inheriting styles from the host document). I don't think it's supported by many browsers yet though.

这篇关于为什么HTML5不包含将本地HTML加载到文档中的方式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆