如何让 iframe 以 50% 的比例显示目标页面及其所有元素?
我的第一个想法是尝试将 css scale 属性写入框架,但我不确定是否可以将 css 写入框架的内容。
谢谢!
最佳答案
由于页面在同一个域中,您可以放置此代码:
<script type="text/javascript">
if (location.href != top.location.href) {
// the page is loaded inside an iframe so
// Make everything 50% scale (I'm not sure what the code for that is in pure js)
// With jQuery:
$("*").css("zoom","50%");
}
</script>
在您正在 iframe 中加载的页面的头部。
如果你不使用 JQuery,这个页面
http://pietschsoft.com/post/2006/06/01/Javascript-Loop-through-all-elements-in-a-form.aspx
有一个很好的例子,说明如何在没有像 JQuery 这样的库的情况下循环遍历表单中的所有元素。
关于javascript - 我怎么能有一个 iframe 以 50% 的比例显示目标页面及其所有元素?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9316088/