在iframe内的iframe中调整图片大小

image resize inside iframe inside iframe
2021-06-20
  •  译文(汉语)
  •  原文(英语)

基本上,我们使用的是gapphotos.com提供的服务,通过该服务,我们可以通过iframe将图像调用到我们的网站中.然后,此iFrame包含另一个保存图像的iframe.我面临的问题是它们的图像大小大致为161x161或320x320.我要做的就是用jQuery进入这两个iFrame,并更改高度/宽度.

var f = $('#iFramePic1');
f.load(function() {
    var iF = f.contents().find('iframe');
    iF.load(function() {
        iF.contents().find('img').height(100);
    });
});

这是我曾经尝试尝试的jQuery,但随着

Blocked a frame with origin "http://localhost:1506" from accessing a frame with 
origin "http://www.gapphotos.com". Protocols, domains, and ports must match.

我调查了EasyXDM,但找不到深入2个iFrame的建议.任何帮助将不胜感激,因为这是一个紧迫的时间表.

在iframe内的iframe中调整图片大小

解决过程1

那将是不可能的,因为iFrame有另一个来源.无法访问iFrame,因为跨域iFrame可能容易被CrossSiteScripting误用

http://en.wikipedia.org/wiki/Same-origin_policy

我不完全知道这是否也适用于css样式,您可能想尝试并使用css来设置自己的高度和宽度...

速聊1:
我知道可以做到这一点,因为拥有gapphoto的人告诉我他已经看到别人在做.我了解xss的局限性,但是像所有其他事情一样,编码通常也有解决的办法.
速聊2:
我尝试添加css,例如iframe iframe img {高度:100像素;宽度:100px;没有运气

Basically we're using a service provided by gapphotos.com where by we can call there images into our site via an iframe. This iFrame then contains another iframe that holds the image. Problem I'm faced with is their images come in two sizes 161x161 or 320x320 roughly. All I want to do is go into these two iFrames with jQuery and alter the height/width.

var f = $('#iFramePic1');
f.load(function() {
    var iF = f.contents().find('iframe');
    iF.load(function() {
        iF.contents().find('img').height(100);
    });
});

This is the jQuery I'd used to try and attempt that but it comes back with the

Blocked a frame with origin "http://localhost:1506" from accessing a frame with 
origin "http://www.gapphotos.com". Protocols, domains, and ports must match.

I've looked into EasyXDM but can't find suggestions to go 2 iFrames deep. Any help would be much appreciated as this is on a tight schedule.

image resize inside iframe inside iframe

Solutions1

That would be impossible, because the iFrame has another origin. The iFrame is not accessible, since cross domain iFrames could be easily missused for CrossSiteScripting

http://en.wikipedia.org/wiki/Same-origin_policy

i don't exacly know if this applies to css styles too, you might want to try and use a css to set your own height and width...

Talk1:
I know that it can be done as the guy that owns gapphoto has told me he's seen someone else do it. I understand the limitations of xss but like all things coding there's normally a way around it.
Talk2:
I've tried adding css such as iframe iframe img { height: 100px; width: 100px; } with no luck
转载于:https://stackoverflow.com/questions/18530612/image-resize-inside-iframe-inside-iframe

本人是.net程序员,因为英语不行,使用工具翻译,希望对有需要的人有所帮助
如果本文质量不好,还请谅解,毕竟这些操作还是比较费时的,英语较好的可以看原文

留言回复
我们只提供高质量资源,素材,源码,坚持 下了就能用 原则,让客户花了钱觉得值
上班时间 : 周一至周五9:00-17:30 期待您的加入