如何增加 iframe 高度以匹配内容
我知道这个问题已经被问过很多次了,并且浏览了很多帖子,但似乎没有一个如此具有限制性。我可能对此无能为力,但我想问一下。
我需要 iframe 中的内容随内容一起增长和缩小。我看到的主要问题是无法使用 javascript,因为提供框架内容的网站只会提供带有指向其内容的链接的 iframe 标记。当然,不能保证放置 iframe 的网站将允许 JavaScript,所以我不认为这是一个选项。
iframe 是否有另一种替代方案,可以让我导入不依赖 javascript 的动态增长和缩小的内容?
I'm aware that this question has been asked a number of time on SO and have looked over many of the posts but none seem to be as restrictive. I may not be able to do anything about this but I want to ask.
I need the content within an iframe to grow and shrink with the content. The main problem that I see is that javascript cannot be used because the site providing the framed content will only provide an iframe tag with a link to its content. There is of course no guarantee that the site where the iframe is placed will allow javascript so I don't see that as an option.
Is there another alternative to an iframe that will allow me to import dynamically growing and shrinking content that doesn't rely on javascript?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您可以在服务器端使用 PHP 来检索内容,然后将其包含在页面中。如果需要,您可以去掉元数据,并使用 Xpath 调整 CSS 和 HTML。
如果这是完全不同的内容,调整 CSS 和 HTML 不起作用,那么 iframe 仍然是唯一的解决方案。如果您可以访问具有 GUI 的服务器,则可以加载页面并将高度存储在数据库中,然后设置加载时 iframe 的高度。
You can use PHP on the server-side to retrieve the content and then include it within the page. You can strip out the meta-data, and adjust the CSS and HTML with Xpath if you need to.
If it's a completely different bit of content for which adjusting the CSS and HTML won't work, then an iframe does remain about the only solution. If you have access to a server with a GUI, you could load the page and store the height in a database, and then set the height of the iframe on load.
试试这个:
http://kinsey.no /blog/index.php/2010/02/19/resizing-iframes-using-easyxdm/
我相信它仍然有效。
Try this:
http://kinsey.no/blog/index.php/2010/02/19/resizing-iframes-using-easyxdm/
I believe it still works.
我想说,以当前的技术和浏览器,这是不可能做到的。没有 JavaScript 就不行。
即使使用 JavaScript,它也不是很漂亮。
I'd say that with current technology and browsers, this just cannot be done. Not without JavaScript.
And it's not pretty even with JavaScript.