Html 如何通过 iframe 嵌入调整大小的网站?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3298210/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to embed a resized website throught an iframe?
提问by xrobot2
I need to embed a website in another website ( throught an iframe I think ). I want to embed this website in this resolution: 200x150 pixel.
我需要在另一个网站中嵌入一个网站(我认为是通过 iframe)。我想以这种分辨率嵌入这个网站:200x150 像素。
How can I do that ?
我怎样才能做到这一点 ?
回答by Alex
Just in case someone wanders in here. Solution in https://stackoverflow.com/a/11382661/605112. Same problem in different context. Set iframe to desired width and height and use CSS to scale it. May not work in all browsers.
以防万一有人在这里闲逛。https://stackoverflow.com/a/11382661/605112 中的解决方案。不同语境下的相同问题。将 iframe 设置为所需的宽度和高度,并使用 CSS 对其进行缩放。可能不适用于所有浏览器。
<iframe width="1024" height="768" src="http://www.bbc.com" style="-webkit-transform:scale(0.5);-moz-transform-scale(0.5);"></iframe>
回答by robjmills
If you mean scale the website down to fit in that frame then you can't.
如果您的意思是缩小网站以适应该框架,那么您就不能。
回答by David
The website would have to be uncommonly small to fit those dimensions.
该网站必须非常小才能适应这些尺寸。
<iframe src="http://www.google.com" width=200px; height=150px;></iframe>
回答by DisgruntledGoat
If you don't have access to the iframed site itself, then there's very little you can do since you can't access iframe from other domains with Javascript.
如果您无权访问 iframe 站点本身,那么您无能为力,因为您无法使用 Javascript 从其他域访问 iframe。
However, if you are able to change the external page, you could either pass a URL parameter or try CSS3 media queries. For the URL parameter you would simply include a secondary stylesheet if the parameter was present that changed the layout or reduced the size of the web page in some way.
但是,如果您能够更改外部页面,则可以传递 URL 参数或尝试CSS3 媒体查询。对于 URL 参数,如果存在以某种方式更改布局或减小网页大小的参数,则您只需包含一个辅助样式表。
回答by Pekka
It's impossible to scale entire web sites programmatically, whether in an iframe or not.
无论是否在 iframe 中,以编程方式扩展整个网站都是不可能的。
You would have to take a screen shot of the embedded page on server side, resize that and serve it as an image.
您必须在服务器端截取嵌入页面的屏幕截图,调整其大小并将其作为图像提供。