我有动态内容,其高度会增长和缩小,需要嵌入到我们不托管或无法控制的其他网站中。我使用 iframe 来做到这一点,但在意识到动态更改 iframe 的高度基本上是不可能的之后,我开始考虑使用 xml。我唯一的要求是容器必须随着导入的数据而增长和收缩。
我可以为此使用 xml 吗?页面加载时我将使用什么标签来获取数据?当页面加载时,数据需要准备好显示。
最佳答案
根据OP的要求复制pasta:
You can embed XML into HTML (using a
<pre>
tag), but how would you expect it to render beyond showing the raw XML text? I also don't see how XML has anything to do with the height of your "dynamic" content. What do you mean by "dynamic content," anyway?While you can associate stylesheets with XML documents that really just doesn't sound like the right approach. Your problem is entirely CSS-related. You just want to be able to change the height of an iframe, right?
I think that the best you'll be able to do is provide a little bit of JavaScript along with the iframe. An iframe is definitely the way to go when it comes to providing a component to be embedded in an arbitrary page, but that means the iframe is at the mercy of the parent page w/r/t placement, dimensions, etc.
关于xml - 我可以将 xml 嵌入到 html 中吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5890973/